Skip to content

Merge pull request #344 from datagouv/update/doc_franceconnect #731

Merge pull request #344 from datagouv/update/doc_franceconnect

Merge pull request #344 from datagouv/update/doc_franceconnect #731

Workflow file for this run

env:
CI: true
COVERAGE: true
defaults:
run:
working-directory: site
name: "Site: CI - CD"
on:
push:
paths:
- 'site/**'
- 'commons/**'
jobs:
security:
name: Brakeman
if: "${{ github.actor != 'dependabot[bot]' }}"
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v7.0.1
- name: Set up Ruby
uses: ruby/setup-ruby@v1.321.0
with:
working-directory: site
- name: Brakeman
uses: reviewdog/action-brakeman@v2
with:
workdir: site
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v7.0.1
- name: Set up Ruby
uses: ruby/setup-ruby@v1.321.0
with:
bundler-cache: true
cache-version: 347
working-directory: site
- name: Run RuboCop
run: bundle exec rubocop --parallel
check-swagger:
name: Check Swagger generation
runs-on: ubuntu-latest
services:
postgres:
image: postgres:latest
env:
POSTGRES_USER: admin_apientreprise
POSTGRES_PASSWORD: wow*verysecret
POSTGRES_DB: admin_apientreprise_test
POSTGRES_PORT: 5432
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
redis:
image: redis
ports: ["6379:6379"]
options: --entrypoint redis-server
steps:
- name: Checkout code
uses: actions/checkout@v7.0.1
- name: Setup ruby
uses: ruby/setup-ruby@v1.321.0
with:
bundler-cache: true
cache-version: 322
working-directory: site
- name: Install postgres client
run: sudo apt-get install libpq-dev
- name: Create database users
env:
POSTGRES_USER: admin_apientreprise
POSTGRES_DB: admin_apientreprise_test
PGPASSWORD: wow*verysecret
run: |
psql -h localhost -U ${{ env.POSTGRES_USER }} -d ${{ env.POSTGRES_DB }} -f `pwd`/postgresql_setup.txt
- name: Create database
run: bundle exec rails db:create db:schema:load RAILS_ENV=test
- name: Check Swagger file is up-to-date
run: ./bin/test_swagger.sh
tests:
name: Tests
runs-on: ubuntu-latest
timeout-minutes: 30
services:
postgres:
image: postgres:latest
env:
POSTGRES_USER: admin_apientreprise
POSTGRES_PASSWORD: wow*verysecret
POSTGRES_DB: admin_apientreprise_test
POSTGRES_PORT: 5432
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
redis:
image: redis
ports: ["6379:6379"]
options: --entrypoint redis-server
steps:
- name: Dump Github context
working-directory: .
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- name: Checkout code
uses: actions/checkout@v7.0.1
- name: Setup ruby
uses: ruby/setup-ruby@v1.321.0
with:
bundler-cache: true
cache-version: 322
working-directory: site
- name: Install postgres client
run: sudo apt-get install libpq-dev
- name: Create database users
env:
POSTGRES_USER: admin_apientreprise
POSTGRES_DB: admin_apientreprise_test
PGPASSWORD: wow*verysecret
run: |
psql -h localhost -U ${{ env.POSTGRES_USER }} -d ${{ env.POSTGRES_DB }} -f `pwd`/postgresql_setup.txt
- name: Create database
run: bundle exec rails db:create db:schema:load RAILS_ENV=test
- name: Run tests
run: bundle exec rspec
- uses: joshmfrankel/simplecov-check-action@main
if: "${{ github.actor != 'dependabot[bot]' }}"
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
minimum_suite_coverage: 90
coverage_path: site/coverage/.last_run.json
merge-with-main:
name: Merge develop with main
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/develop'
needs:
- security
- lint
- check-swagger
- tests
steps:
- name: Checkout code
uses: actions/checkout@v7.0.1
- name: Force push develop to main
working-directory: .
run: |
git push --force origin develop:main
continuous-deployment-staging:
name: Continuous deployment on staging
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/develop'
needs:
- security
- lint
- check-swagger
- tests
- merge-with-main
timeout-minutes: 10
strategy:
matrix:
host: [watchdoge3, watchdoge4]
fail-fast: false
environment: staging
env:
DEPLOY_HTTPS_LOGIN: ${{ secrets.DEPLOY_HTTPS_LOGIN }}
DEPLOY_HTTPS_PASSWORD: ${{ secrets.DEPLOY_HTTPS_PASSWORD }}
DEPLOY_HTTPS_REQUEST_URL: ${{ vars.DEPLOY_HTTPS_REQUEST_URL }}
DEPLOY_HTTPS_RESPONSE_URL: ${{ vars.DEPLOY_HTTPS_RESPONSE_URL }}
DEPLOY_HOST: host_${{ matrix.host }}
DEPLOY_APP: admin_apientreprise_staging
steps:
- name: Download and run deploy script
shell: bash
working-directory: .
run: |
git clone https://github.com/etalab/api-entreprise-integration
cd api-entreprise-integration
./deploy-parteprise.sh
continuous-deployment-production:
name: Continuous deployment on production
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/develop'
needs:
- security
- lint
- check-swagger
- tests
- merge-with-main
- continuous-deployment-staging
timeout-minutes: 20
strategy:
matrix:
host: [watchdoge3, watchdoge4]
fail-fast: false
environment: production
env:
DEPLOY_HTTPS_LOGIN: ${{ secrets.DEPLOY_HTTPS_LOGIN }}
DEPLOY_HTTPS_PASSWORD: ${{ secrets.DEPLOY_HTTPS_PASSWORD }}
DEPLOY_HTTPS_REQUEST_URL: ${{ vars.DEPLOY_HTTPS_REQUEST_URL }}
DEPLOY_HTTPS_RESPONSE_URL: ${{ vars.DEPLOY_HTTPS_RESPONSE_URL }}
DEPLOY_HOST: host_${{ matrix.host }}
DEPLOY_APP: admin_apientreprise_production
steps:
- name: Download and run deploy script
shell: bash
working-directory: .
run: |
git clone https://github.com/etalab/api-entreprise-integration
cd api-entreprise-integration
./deploy-parteprise.sh