Skip to content

Commit

Permalink
Merge pull request #271 from Clochette-AbsINThe/dev
Browse files Browse the repository at this point in the history
🔖 Release 3.0.0
  • Loading branch information
SamuelGuillemet authored Jan 19, 2024
2 parents af4b617 + f2b1509 commit 823b953
Show file tree
Hide file tree
Showing 572 changed files with 51,016 additions and 17,116 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ frontend/node_modules
frontend/.next
frontend/coverage
frontend/tests
backend/.venv
backend/.pytest_cache
backend/test
53 changes: 53 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Contributing to clochette

When contributing to this repository, please first discuss the change you wish to
make via issue with the owners of this repository before making a change.

## Branching

If you would like to contribute to this project, you will need to use
[git flow](https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow). This way, any and all changes
happen on the development branch and not on the main branch. As such, after
you have git-flow-ified your `ms-python-client` git repo (`git flow init`), create a pull request for your
branch, and we'll take it from there.

## Git Commit guidelines

1. Separate subject from body with a blank line
2. Limit the subject line to 50 characters
3. Capitalize the subject line
4. Do not end the subject line with a period
5. Use the imperative mood in the subject line
6. Wrap the body at 72 characters
7. Use the body to explain what and why vs. how

Source: https://chris.beams.io/posts/git-commit/

## Pull request guidelines

> :warning: When submitting a Pull Request to this project for something more than a typo or small bug,
> **please make sure your idea was discussed beforehand** with the development team, via an
> [issue](https://github.com/bocabitlabs/buho-stocks/issues/new/choose).
Open Source is about contributing back, but it's important to know how to do it in the best way possible.
We don't want you to spend your precious time in a "ping-pong" of code reviews that will end up not being fun.
We also want to maximize the chances that your contribution will already be done following what we consider good practices.

1. The subject line should be a one-sentence summary, and should not include
the word _and_ (explicitly or implied).
2. Any extra detail should be provided in the body of the PR.
3. Don't submit unrelated changes in the same pull request.
4. If you had a bit of churn in the process of getting the change right,
squash your commits. Refer to the guidelines on [squashing commits](git-basics.md#squashing).
5. If you had to refactor in order to add your change, then we'd love to
see two commits: First the refactoring, then the added behavior. It's
fine to put this in the same pull request, unless the refactoring is
huge and would make it hard to review both at the same time.
6. If you are referencing another issue or pull-request, for instance
_closes #XXX_, _see #XXX_, please include the reference in the body of the PR,
rather than the subject line. This is simply because the subject line doesn't
support markdown, and so these don't get turned into clickable links. It makes
it harder to follow and to go look at the related issue or PR.
7. Please also refer to the guidelines for [commit messages](git-basics.md#commit-messages).

Once you've submitted a pull request, one or more of the maintainers will review it if all checks (tests and coverage pass).
41 changes: 41 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
commit-message:
prefix:
groups:
github-actions:
patterns:
- "*"

- package-ecosystem: "npm"
directory: "/frontend"
schedule:
interval: "weekly"
commit-message:
prefix:
groups:
production-dependencies:
dependency-type: production
development-dependencies:
dependency-type: development

- package-ecosystem: "pip"
directory: "/backend"
schedule:
interval: "weekly"
commit-message:
prefix:
groups:
production-dependencies:
dependency-type: production
development-dependencies:
dependency-type: development
71 changes: 71 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Build and push Docker images

on:
workflow_run:
workflows: ["Release on push to main branch"]
branches: [main]
types:
- completed

env:
GH_REGISTRY: ghcr.io

jobs:
get-version:
if: github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
outputs:
tag_name: ${{ steps.get-tag-name.outputs.tag_name }}
steps:
- name: Download artifact
uses: actions/github-script@v7
with:
script: |
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
return artifact.name == "version_number"
})[0];
let download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
let fs = require('fs');
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/version_number.zip`, Buffer.from(download.data));
- name: Unzip artifact
run: unzip version_number.zip

- name: Get tag name
id: get-tag-name
run: |
echo "tag_name=$(cat version_number)" >> $GITHUB_OUTPUT
build-and-push:
runs-on: ubuntu-latest
needs: get-version
if: needs.get-version.outputs.tag_name != ''
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.GH_REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker-Compose images
run: |
cd docker
docker compose -f docker-compose.yml -f docker-compose.prod.yml build
docker compose -f docker-compose.yml -f docker-compose.prod.yml push
export tag=${{ needs.get-version.outputs.tag_name }}
docker compose -f docker-compose.yml -f docker-compose.prod.yml build
docker compose -f docker-compose.yml -f docker-compose.prod.yml push
24 changes: 24 additions & 0 deletions .github/workflows/dependabot-auto-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Dependabot auto-merge
on: pull_request

permissions:
contents: write
pull-requests: write

jobs:
dependabot:
runs-on: ubuntu-latest
# Disable this workflow for now
if: ${{ github.actor == 'dependabot[bot]' && 1 == 0 }}
steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v1
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
- name: Enable auto-merge for Dependabot PRs
if: ${{steps.metadata.outputs.update-type == 'version-update:semver-patch'}}
run: gh pr merge --auto --merge "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
39 changes: 39 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Deploy

on:
workflow_run:
workflows: ["Build and push Docker images"]
branches: [main]
types:
- completed
workflow_dispatch:

env:
REGISTRY: ghcr.io

jobs:
deploy:
if: github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
env:
REGISTRY: ghcr.io
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPOSITORY_OWNER: ${{ github.repository_owner }}
REPOSITORY: ${{ github.repository }}
steps:
- name: Deploy to production
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
envs: REGISTRY,GITHUB_TOKEN,REPOSITORY,REPOSITORY_OWNER
script: |
echo $GITHUB_TOKEN | docker login $REGISTRY -u $REPOSITORY_OWNER --password-stdin
cd clochette
rm -f docker-compose.yml docker-compose.prod.yml
wget https://raw.githubusercontent.com/$REPOSITORY/main/docker/docker-compose.yml
wget https://raw.githubusercontent.com/$REPOSITORY/main/docker/docker-compose.prod.yml
docker compose -f docker-compose.yml -f docker-compose.prod.yml pull
docker compose -f docker-compose.yml -f docker-compose.prod.yml up -d
docker image prune -f -a
20 changes: 20 additions & 0 deletions .github/workflows/docker-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Test build docker

on:
pull_request:
branches: [dev, main]

defaults:
run:
working-directory: docker

jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Build Docker-Compose images
run: |
docker compose -f docker-compose.yml -f docker-compose.prod.yml build
34 changes: 27 additions & 7 deletions .github/workflows/frontend-checks.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: This workflow aims to check the frontend code when push to the dev branch with lint, format, tests and build.
name: Frontend Checks

on:
push:
branches: [dev]
pull_request:
branches: [dev]
branches: [dev, main]

defaults:
run:
Expand All @@ -14,13 +14,13 @@ jobs:
frontend-checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: "18"
cache-dependency-path: frontend/package.json
cache-dependency-path: frontend/package-lock.json
cache: "npm"

- name: Install dependencies
Expand All @@ -35,8 +35,28 @@ jobs:
- name: Test frontend and get coverage
run: npm run coverage

- name: Save coverage report
uses: actions/upload-artifact@v4
with:
name: coverage-report-frontend
path: ./frontend/coverage/coverage-final.json

coverage:
needs: frontend-checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Download coverage report
uses: actions/download-artifact@v4
with:
name: coverage-report-frontend
path: ./frontend/coverage

- name: Upload coverage reports to Codecov with GitHub Action
uses: codecov/codecov-action@v3
with:
files: ./coverage/coverage-final.json
working-directory: frontend
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
files: ./frontend/coverage/coverage-final.json
flags: frontend
15 changes: 15 additions & 0 deletions .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: pre-commit

on:
push:
branches: [dev]
pull_request:
branches: [dev, main]

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: pre-commit/[email protected]
Loading

0 comments on commit 823b953

Please sign in to comment.