Skip to content

Commit

Permalink
Remove circle and improve gha (#1089)
Browse files Browse the repository at this point in the history
* Remove circle and improve gha

* Main workflow

* Tag workflow

* deploy to siap integration independently

---------

Co-authored-by: Nicolas Oudard <[email protected]>
  • Loading branch information
syldb and kolok authored Dec 15, 2023
1 parent d2c6daa commit f89c73f
Show file tree
Hide file tree
Showing 5 changed files with 168 additions and 5 deletions.
File renamed without changes.
40 changes: 40 additions & 0 deletions .github/workflows/push-branch-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: "Test and deploy to staging"
on:
push:
branches:
- main

env:
DATABASE_URL: postgres://apilos:apilos@localhost:5432/apilos
DB_READONLY: postgres://apilos:apilos@localhost:5432/apilos
SECRET_KEY: secret-key
DEBUG: False

jobs:
test:
uses: ./.github/workflows/run_tests.yml

deploy_to_staging:
name: "Deploy to Staging"
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout repository
uses: actions/checkout@v4
- uses: kolok/deploy-to-scalingo@v1
with:
ssh-private-key: ${{ secrets.SCALINGO_SSH_PRIVATE_KEY }}
app-name: apilos-staging
known-host: ssh.osc-fr1.scalingo.com
deploy_to_siap_integration:
name: "Deploy to Siap Integration"
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout repository
uses: actions/checkout@v4
- uses: kolok/deploy-to-scalingo@v1
with:
ssh-private-key: ${{ secrets.SCALINGO_SSH_PRIVATE_KEY }}
app-name: apilos-siap-integration
known-host: ssh.osc-fr1.scalingo.com
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
name: "coverage"
name: "Test and check"
on:
- pull_request


# Explicitely set permissions to allow Dependabot workflow runs to write in the PR
# for coverage's reporting.
# By default, these are read-only when the actions are ran by Dependabot
# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/automating-dependabot-with-github-actions#changing-github_token-permissions
permissions:
pull-requests: write

env:
DATABASE_URL: postgres://apilos:apilos@localhost:5432/apilos
DB_READONLY: postgres://apilos:apilos@localhost:5432/apilos
SECRET_KEY: secret-key
DEBUG: False

jobs:
coverage:
name: Test & Coverage
Expand Down Expand Up @@ -42,12 +47,12 @@ jobs:
python-version: "3.10"
- name: Install dependencies
run: pip install -r requirements.txt -r dev-requirements.txt
- name: Check migrations
run: |
python manage.py makemigrations --check --dry-run
- name: Execute test with coverage
run: |
coverage run --source='.' manage.py test
env:
DATABASE_URL: postgres://apilos:apilos@localhost:5432/apilos
DB_READONLY: postgres://apilos:apilos@localhost:5432/apilos
- name: Create coverage report
run: coverage xml -o coverage.xml
- name: Post coverage to PR
Expand Down
67 changes: 67 additions & 0 deletions .github/workflows/push-version-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: "Test and deploy to staging"
on:
push:
tags:
- "v*.*.*"

env:
DATABASE_URL: postgres://apilos:apilos@localhost:5432/apilos
DB_READONLY: postgres://apilos:apilos@localhost:5432/apilos
SECRET_KEY: secret-key
DEBUG: False

jobs:
test:
uses: ./.github/workflows/run_tests.yml

deploy_to_production:
name: "Deploy to Production"
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout repository
uses: actions/checkout@v4
- uses: kolok/deploy-to-scalingo@v1
with:
ssh-private-key: ${{ secrets.SCALINGO_SSH_PRIVATE_KEY }}
app-name: fabnum-apilos
known-host: ssh.osc-fr1.scalingo.com

deploy_to_siap_production:
name: "Deploy to Siap Production"
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout repository
uses: actions/checkout@v4
- uses: kolok/deploy-to-scalingo@v1
with:
ssh-private-key: ${{ secrets.SCALINGO_SSH_PRIVATE_KEY }}
app-name: apilos-siap-production
known-host: ssh.osc-fr1.scalingo.com

deploy_to_siap_recette:
name: "Deploy to Siap Recette"
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout repository
uses: actions/checkout@v4
- uses: kolok/deploy-to-scalingo@v1
with:
ssh-private-key: ${{ secrets.SCALINGO_SSH_PRIVATE_KEY }}
app-name: apilos-siap-recette
known-host: ssh.osc-fr1.scalingo.com

deploy_to_siap_ecole:
name: "Deploy to Siap École"
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout repository
uses: actions/checkout@v4
- uses: kolok/deploy-to-scalingo@v1
with:
ssh-private-key: ${{ secrets.SCALINGO_SSH_PRIVATE_KEY }}
app-name: apilos-siap-ecole
known-host: ssh.osc-fr1.scalingo.com
51 changes: 51 additions & 0 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
on:
workflow_call:

defaults:
run:
shell: bash

env:
DATABASE_URL: postgres://apilos:apilos@localhost:5432/apilos
DB_READONLY: postgres://apilos:apilos@localhost:5432/apilos
SECRET_KEY: secret-key
DEBUG: False

jobs:
test:
name: Test

# Service containers to run with `container-job`
services:
# Label used to access the service container
postgres:
image: postgres
ports:
- 5432:5432
env:
POSTGRES_USER: apilos
POSTGRES_NAME: apilos
POSTGRES_HOST: postgres
POSTGRES_PASSWORD: apilos
POSTGRES_PORT: 5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install dependencies
run: pip install -r requirements.txt -r dev-requirements.txt
- name: Check migrations
run: |
python manage.py makemigrations --check --dry-run
- name: Execute test
run: |
python manage.py test

0 comments on commit f89c73f

Please sign in to comment.