fixup! Ajuste aux évolutions côté AJ #30
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Continuous Integration" | |
on: | |
push: | |
branches: [main, dev] | |
pull_request: | |
workflow_dispatch: | |
env: | |
OPENFISCA_BIND_HOST: 127.0.0.1:2000 | |
LC_ALL: C.UTF-8 | |
LANG: C.UTF-8 | |
PYTHON_VERSION: 3.11.4 | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
install: | |
name: Install | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Cache NPM install files | |
uses: actions/cache@v3 | |
id: restore-npm-install-packages | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-cache-npm-${{ hashFiles('**/package-lock.json') }} | |
- name: Cache node modules | |
uses: actions/cache@v3 | |
id: restore-dependencies | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-cache-node-modules-${{ hashFiles('**/package-lock.json') }} | |
- name: Check tool versions | |
run: npm --version && node --version | |
- name: Install dependencies | |
if: steps.restore-dependencies.outputs.cache-hit != 'true' | |
run: npm ci --prefer-offline --no-audit | |
install_openfisca: | |
name: Install OpenFisca | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Cache Virtual Environment | |
uses: actions/cache@v3 | |
id: python-dependencies | |
with: | |
path: .venv | |
key: ${{ runner.os }}-cache-python-dependencies-${{ env.PYTHON_VERSION }}-${{ hashFiles('**/openfisca/requirements.txt') }} | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- name: Setup VirtualEnv | |
run: | | |
python -m venv .venv | |
- name: Install dependencies | |
shell: bash | |
run: | | |
source .venv/bin/activate | |
pip3 install -r openfisca/requirements.txt 2> ci-err.log | |
test -n ci-err.log && grep incompatible ci-err.log && cat ci-err.log && exit 1 | |
rm ci-err.log | |
deactivate | |
lint: | |
name: Lint | |
needs: [install] | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Restore node modules | |
uses: actions/cache@v3 | |
id: restore-dependencies | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-cache-node-modules-${{ hashFiles('**/package-lock.json') }} | |
- name: Run ESLint | |
run: npm run lint | |
- name: Run Prettier | |
run: npm run prettier:check | |
check_data_file_consistency: | |
name: Check data file consistency | |
needs: [install] | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Restore node modules | |
uses: actions/cache@v3 | |
id: restore-dependencies | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-cache-node-modules-${{ hashFiles('**/package-lock.json') }} | |
- name: Run schema-validation-config.spec.ts | |
run: npm run test -- tests/integration/schema-validation-config.spec.ts | |
unit_tests: | |
name: Unit tests | |
needs: [install, check_data_file_consistency] | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Restore node modules | |
uses: actions/cache@v3 | |
id: restore-dependencies | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-cache-node-modules-${{ hashFiles('**/package-lock.json') }} | |
- name: Jest | |
run: npm run test | |
build: | |
name: Build | |
needs: [install] | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Restore node modules | |
uses: actions/cache@v3 | |
id: restore-dependencies | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-cache-node-modules-${{ hashFiles('**/package-lock.json') }} | |
- name: Cache build output | |
uses: actions/cache@v3 | |
id: restore-build | |
with: | |
path: dist | |
key: ${{ runner.os }}-cache-build-${{ github.sha }} | |
- name: Cache server build output | |
uses: actions/cache@v3 | |
id: restore-server-build | |
with: | |
path: dist-server | |
key: ${{ runner.os }}-cache-server-build-${{ github.sha }} | |
- name: Build assets | |
run: | | |
npm run build | |
build_contribuer: | |
name: Build contribuer/ static site | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Restore contribuer/node_modules | |
uses: actions/cache@v3 | |
id: restore-contribuer-dependencies | |
with: | |
path: contribuer/node_modules | |
key: ${{ runner.os }}-cache-contribuer-node-modules-${{ hashFiles('contribuer/package-lock.json') }} | |
- name: Install dependencies | |
if: steps.restore-contribuer-dependencies.outputs.cache-hit != 'true' | |
run: cd contribuer && npm ci --prefer-offline --no-audit | |
- name: Restore contribuer/.next/cache | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.npm | |
${{ github.workspace }}/contribuer/.next/cache | |
key: ${{ runner.os }}-nextjs-${{ hashFiles('contribuer/package-lock.json') }}-${{ hashFiles('contribuer/**.[jt]s', 'contribuer/**.[jt]sx') }} | |
restore-keys: | | |
${{ runner.os }}-nextjs-${{ hashFiles('contribuer/package-lock.json') }}- | |
- name: Build static site | |
run: cd contribuer && npm run export | |
openfisca_test_generation: | |
name: OpenFisca test generation | |
needs: [install, install_openfisca, check_data_file_consistency] | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- name: Restore node modules | |
uses: actions/cache@v3 | |
id: restore-dependencies | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-cache-node-modules-${{ hashFiles('**/package-lock.json') }} | |
- name: Cache Virtual Environment | |
uses: actions/cache@v3 | |
id: python-dependencies | |
with: | |
path: .venv | |
key: ${{ runner.os }}-cache-python-dependencies-${{ env.PYTHON_VERSION }}-${{ hashFiles('**/openfisca/requirements.txt') }} | |
- name: Validate OpenFisca test generation | |
shell: bash | |
run: | | |
source .venv/bin/activate | |
npm run test tests/unit/openfisca/test.spec.ts | |
iframe_build_control: | |
name: Iframe build control | |
needs: [install] | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Restore node modules | |
uses: actions/cache@v3 | |
id: restore-dependencies | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-cache-node-modules-${{ hashFiles('**/package-lock.json') }} | |
- name: Build assets | |
run: | | |
cp .env.iframe_build_control .env | |
npm run build:iframes | |
- name: Validate Iframe build | |
shell: bash | |
run: "npm run tools:test-iframe-generation" | |
test_e2e: | |
name: End-to-End Tests | |
needs: [build, install_openfisca] | |
runs-on: ubuntu-20.04 | |
timeout-minutes: 15 | |
services: | |
mongodb: | |
image: mongo:6.0.8 | |
ports: | |
- 27017:27017 | |
strategy: | |
matrix: | |
test: [base, family, handicap, patrimoine, student] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- name: Restore node modules | |
uses: actions/cache@v3 | |
id: restore-dependencies | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-cache-node-modules-${{ hashFiles('**/package-lock.json') }} | |
- name: Cache Cypress installation | |
uses: actions/cache@v3 | |
id: restore-cypress | |
with: | |
path: ~/.cache/Cypress | |
key: ${{ runner.os }}-cache-cypress-${{ hashFiles('**/package-lock.json') }} | |
- name: Cache Virtual Environment | |
uses: actions/cache@v3 | |
id: python-dependencies | |
with: | |
path: .venv | |
key: ${{ runner.os }}-cache-python-dependencies-${{ env.PYTHON_VERSION }}-${{ hashFiles('**/openfisca/requirements.txt') }} | |
- name: Cache build output | |
uses: actions/cache@v3 | |
id: restore-build | |
with: | |
path: dist | |
key: ${{ runner.os }}-cache-build-${{ github.sha }} | |
- name: Cache server build output | |
uses: actions/cache@v3 | |
id: restore-server-build | |
with: | |
path: dist-server | |
key: ${{ runner.os }}-cache-server-build-${{ github.sha }} | |
- name: Start OpenFisca | |
shell: bash | |
run: | | |
source .venv/bin/activate | |
nohup gunicorn api --chdir openfisca/ --config openfisca/config.py --preload --log-level debug --log-file=- & | |
deactivate | |
- name: Cypress install | |
uses: cypress-io/github-action@v5 | |
if: steps.restore-cypress.outputs.cache-hit != 'true' | |
with: | |
browser: chrome | |
config-file: cypress.config.ts | |
runTests: false | |
- name: Copy cypress env file | |
run: cp .env.e2e .env | |
- name: Cypress run | |
uses: cypress-io/github-action@v5 | |
with: | |
browser: chrome | |
config-file: cypress.config.ts | |
start: npm run ci | |
wait-on: "http://127.0.0.1:8080, http://127.0.0.1:2000/variable/parisien, http://127.0.0.1:27017" | |
install: false | |
spec: cypress/e2e/${{matrix.test}}.cy.js | |
- name: Upload cypress videos | |
uses: actions/upload-artifact@v3 | |
if: failure() | |
with: | |
name: cypress-video-${{matrix.test}} | |
path: | | |
cypress/videos | |
cypress/screenshots | |
retention-days: 10 | |
- name: Upload cypress payloads | |
uses: actions/upload-artifact@v4 | |
with: | |
name: cypress-json-${{matrix.test}} | |
path: cypress/payloads | |
check-for-openfisca-requirements-changes: | |
name: Check openfisca requirement changes | |
runs-on: ubuntu-20.04 | |
timeout-minutes: 15 | |
outputs: | |
status: ${{ steps.stop-early.outputs.status }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- id: stop-early | |
run: if "${GITHUB_WORKSPACE}/.github/has-file-changes.sh" "${GITHUB_WORKSPACE}/openfisca/requirements.txt" ; then echo "status=success" >> $GITHUB_OUTPUT ; fi | |
test_definition_periods: | |
name: Openfisca definition periods tests | |
needs: | |
[ | |
check-for-openfisca-requirements-changes, | |
install, | |
install_openfisca, | |
build, | |
] | |
if: needs.check-for-openfisca-requirements-changes.outputs.status == 'success' | |
runs-on: ubuntu-20.04 | |
timeout-minutes: 15 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "18.18.2" | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- name: Restore node modules | |
uses: actions/cache@v3 | |
id: restore-dependencies | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-cache-node-modules-${{ hashFiles('**/package-lock.json') }} | |
- name: Cache Virtual Environment | |
uses: actions/cache@v3 | |
id: python-dependencies | |
with: | |
path: .venv | |
key: ${{ runner.os }}-cache-python-dependencies-${{ env.PYTHON_VERSION }}-${{ hashFiles('**/openfisca/requirements.txt') }} | |
- name: Cache server build output | |
uses: actions/cache@v3 | |
id: restore-server-build | |
with: | |
path: dist-server | |
key: ${{ runner.os }}-cache-server-build-${{ github.sha }} | |
- name: Start OpenFisca | |
shell: bash | |
run: | | |
source .venv/bin/activate | |
nohup gunicorn api --chdir openfisca/ --config openfisca/config.py --preload --log-level debug --log-file=- & | |
deactivate | |
- name: Wait openfisca | |
shell: bash | |
run: wget --retry-connrefused --waitretry=2 --output-document=/dev/null http://localhost:2000/variable/parisien | |
- name: Test definition periods | |
shell: bash | |
run: npm run tools:test-definition-periods | |
test_benefit_file_changes: | |
name: Test benefit file changes | |
needs: [install] | |
runs-on: ubuntu-20.04 | |
outputs: | |
status: ${{ steps.has-changes.outputs.status }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Restore node modules | |
uses: actions/cache@v3 | |
id: restore-dependencies | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-cache-node-modules-${{ hashFiles('**/package-lock.json') }} | |
- id: has-changes | |
run: | | |
if "${GITHUB_WORKSPACE}/.github/has-file-changes.sh" "${GITHUB_WORKSPACE}/data/benefits" ; then | |
echo "status=success" >> $GITHUB_OUTPUT | |
fi | |
check_benefit_link_improvements: | |
name: Check benefit link improvements and update link table if necessary | |
needs: [test_benefit_file_changes] | |
if: needs.test_benefit_file_changes.outputs.status == 'success' | |
runs-on: ubuntu-20.04 | |
timeout-minutes: 60 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "18.18.2" | |
- name: Restore node modules | |
uses: actions/cache@v3 | |
id: restore-dependencies | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-cache-node-modules-${{ hashFiles('**/package-lock.json') }} | |
- name: Test | |
shell: bash | |
run: npm run tools:check-links-validity -- --no-priority | |
env: | |
GRIST_DOC_ID: ${{ secrets.GRIST_DOC_ID }} | |
GRIST_API_KEY: ${{ secrets.GRIST_API_KEY }} | |
ci_failed: | |
name: Detect failure | |
runs-on: ubuntu-20.04 | |
needs: | |
[ | |
install, | |
install_openfisca, | |
lint, | |
unit_tests, | |
build, | |
build_contribuer, | |
openfisca_test_generation, | |
iframe_build_control, | |
test_e2e, | |
] | |
if: always() && github.ref == 'refs/heads/main' && (needs.install.result == 'failure' || needs.install_openfisca.result == 'failure' || needs.lint.result == 'failure' || needs.unit_tests.result == 'failure' || needs.build.result == 'failure' || needs.build_contribuer.result == 'failure' || needs.openfisca_test_generation.result == 'failure' || needs.iframe_build_control.result == 'failure' || needs.test_e2e.result == 'failure') | |
steps: | |
- name: Send CI failed message | |
shell: bash | |
run: | | |
curl -i -X POST -H 'Content-Type: application/json' -d '{"text": ":icon-danger: [équipe-tech] La CI a rencontré un problème sur la branche main ([lien](https://github.com/betagouv/aides-jeunes/actions/workflows/ci.yml?query=branch%3Amain+is%3Afailure))"}' ${{ secrets.MATTERMOST_ALERTING_URL }} |