Skip to content

(BSR)[API] refactor: rename imports in core educational #17695

(BSR)[API] refactor: rename imports in core educational

(BSR)[API] refactor: rename imports in core educational #17695

name: "1 [on_push] Initiate workflow"
on:
push:
branches:
- master
- "maint/**"
permissions: write-all
jobs:
pcapi-init-job:
name: "pcapi init job"
runs-on: ubuntu-22.04
outputs:
api-changed: ${{ steps.check-api-changes.outputs.any_modified }}
api-documentation-changed: ${{ steps.check-api-documentation-changes.outputs.any_modified }}
pro-changed: ${{ steps.check-pro-changes.outputs.any_modified }}
dependencies-changed: ${{ steps.check-dependencies-changes.outputs.any_modified }}
algolia-config-changed: ${{ steps.check-algolia-config-changes.outputs.any_modified }}
push-tags: ${{ steps.pcapi-tags.outputs.push-tags }}
checksum-tag: ${{ steps.pcapi-tags.outputs.checksum-tag }}
checksum-tag-exists: ${{ steps.check-checksum-tag.outputs.tag-exists }}
checksum-console-tag-exists: ${{ steps.check-console-checksum-tag.outputs.tag-exists }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
fetch-tags: false
- name: "Check api folder changes"
id: check-api-changes
uses: tj-actions/changed-files@v47
with:
files: |
api/**
!api/documentation/**
!api/src/pcapi/scripts/**/main.py
!api/src/pcapi/scripts/**/main.sql
- name: "Check api documentation folder changes"
id: check-api-documentation-changes
uses: tj-actions/changed-files@v47
with:
files: api/documentation/**
- name: "Check pro folder changes"
id: check-pro-changes
uses: tj-actions/changed-files@v47
with:
files: |
.github/workflows/dev_on_push_workflow.yml
.github/workflows/dev_on_workflow_tests_pro.yml
.github/workflows/dev_on_workflow_tests_pro_e2e.yml
pro/**
- name: "Check changes in dependencies (frontend + backend)"
id: check-dependencies-changes
uses: tj-actions/changed-files@v47
with:
files: |
api/poetry.lock
pro/yarn.lock
- name: "Check changes in Algolia configuration"
id: check-algolia-config-changes
uses: tj-actions/changed-files@v47
with:
files: |
api/src/pcapi/algolia_settings_collective_offers.json
api/src/pcapi/algolia_settings_offers.json
api/src/pcapi/algolia_settings_venues.json
- name: "Define pcapi image tags."
id: pcapi-tags
run: |
DOCKER_IMAGE="${{ env.docker_registry }}/pcapi"
API_CHECKSUM=`tar --sort=name --owner=0 --group=0 --mtime='UTC 2019-01-01' -cf - api | sha1sum | awk '{ print $1 }'`
PUSH_TAGS="push-tags=$DOCKER_IMAGE:${{ github.sha }},$DOCKER_IMAGE:$API_CHECKSUM,$DOCKER_IMAGE:latest"
API_TAG="checksum-tag=$API_CHECKSUM"
echo "PUSH_TAGS=$PUSH_TAGS"
echo "API_TAG=$API_TAG"
echo $PUSH_TAGS >> "$GITHUB_OUTPUT"
echo $API_TAG >> "$GITHUB_OUTPUT"
- name: "Summary"
run: |
echo "[api] folder changed : ${{ steps.check-api-changes.outputs.any_modified }}"
echo "[algolia] folder changed : ${{ steps.check-algolia-config-changes.outputs.any_modified }}"
echo "[pcapi] push-tags : ${{ steps.pcapi-tags.outputs.push-tags }}"
echo "[pcapi] checksum-tag : ${{ steps.pcapi-tags.outputs.checksum-tag }}"
check-folders-changes:
# Perform all changes checks at once to remove the need for multiple checkouts accross jobs
name: "Check changes in folders"
runs-on: ubuntu-22.04
outputs:
maintenance-site-changed: ${{ steps.check-maintenance-site-changes.outputs.any_modified }}
db-migrations-changed: ${{ steps.check-db-migrations-changes.outputs.any_modified }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
fetch-tags: false
- name: "Check maintenance-site folder changes"
id: check-maintenance-site-changes
uses: tj-actions/changed-files@v47
with:
files: maintenance-site/**
- name: "Check db migration folder changes"
id: check-db-migrations-changes
uses: tj-actions/changed-files@v47
with:
files: |-
api/src/pcapi/alembic/versions/**
api/src/pcapi/alembic/run_migrations.py
build-pcapi-tests:
name: "[pcapi-tests] build docker image."
needs: [pcapi-init-job]
if: needs.pcapi-init-job.outputs.api-changed == 'true' || needs.pcapi-init-job.outputs.pro-changed == 'true'
uses: ./.github/workflows/dev_on_workflow_build_docker_image.yml
with:
image: pcapi-tests
tag: ${{ github.sha }}
prepare-cache-master: # on "master" branch only
name: "Reset cache on master on dependency update"
needs: [build-pcapi-tests]
uses: ./.github/workflows/dev_on_workflow_update_api_client_template.yml
if: github.ref == 'refs/heads/master'
with:
PCAPI_DOCKER_TAG: ${{ github.sha }}
TRIGGER_ONLY_ON_API_CHANGE: false
TRIGGER_ONLY_ON_DEPENDENCY_CHANGE: true
CACHE_BUCKET_NAME: "passculture-infra-prod-github-runner-cache"
api-changed: ${{ needs.pcapi-init-job.outputs.api-changed }}
dependencies-changed: ${{ needs.pcapi-init-job.outputs.dependencies-changed }}
secrets:
GCP_EHP_SERVICE_ACCOUNT: ${{ secrets.GCP_EHP_SERVICE_ACCOUNT }}
GCP_EHP_WORKLOAD_IDENTITY_PROVIDER: ${{ secrets.GCP_EHP_WORKLOAD_IDENTITY_PROVIDER }}
test-api:
name: "Test api"
needs: [pcapi-init-job, build-pcapi-tests]
if: needs.pcapi-init-job.outputs.api-changed == 'true'
uses: ./.github/workflows/dev_on_workflow_tests_api.yml
with:
tag: ${{ needs.build-pcapi-tests.result == 'skipped' && 'latest' || github.sha }}
secrets:
GCP_EHP_SERVICE_ACCOUNT: ${{ secrets.GCP_EHP_SERVICE_ACCOUNT }}
GCP_EHP_WORKLOAD_IDENTITY_PROVIDER: ${{ secrets.GCP_EHP_WORKLOAD_IDENTITY_PROVIDER }}
test-api-documentation:
name: "Tests API documentation"
needs: [pcapi-init-job]
if: needs.pcapi-init-job.outputs.api-documentation-changed == 'true'
uses: ./.github/workflows/dev_on_workflow_tests_api_documentation.yml
secrets:
GCP_EHP_SERVICE_ACCOUNT: ${{ secrets.GCP_EHP_SERVICE_ACCOUNT }}
GCP_EHP_WORKLOAD_IDENTITY_PROVIDER: ${{ secrets.GCP_EHP_WORKLOAD_IDENTITY_PROVIDER }}
test-pro:
name: "Pro Unit Tests"
needs: [pcapi-init-job]
if: needs.pcapi-init-job.outputs.pro-changed == 'true'
uses: ./.github/workflows/dev_on_workflow_tests_pro.yml
with:
CACHE_BUCKET_NAME: "passculture-infra-prod-github-runner-cache"
secrets:
GCP_EHP_WORKLOAD_IDENTITY_PROVIDER: ${{ secrets.GCP_EHP_WORKLOAD_IDENTITY_PROVIDER }}
GCP_EHP_SERVICE_ACCOUNT: ${{ secrets.GCP_EHP_SERVICE_ACCOUNT }}
test-pro-e2e-parallel:
name: "Pro E2E Tests (Parallel)"
needs: [pcapi-init-job, build-pcapi-tests]
uses: ./.github/workflows/dev_on_workflow_tests_pro_e2e.yml
if: always() &&
!cancelled() &&
needs.pcapi-init-job.outputs.api-changed == 'true' ||
needs.pcapi-init-job.outputs.pro-changed == 'true'
with:
ENV: "development"
tag: ${{ needs.build-pcapi-tests.result == 'skipped' && 'latest' || github.sha }}
CACHE_BUCKET_NAME: "passculture-infra-prod-github-runner-cache"
secrets:
GCP_EHP_WORKLOAD_IDENTITY_PROVIDER: ${{ secrets.GCP_EHP_WORKLOAD_IDENTITY_PROVIDER }}
GCP_EHP_SERVICE_ACCOUNT: ${{ secrets.GCP_EHP_SERVICE_ACCOUNT }}
deploy-storybook:
name: "Deploy Storybook"
needs: [pcapi-init-job]
if: ${{ github.ref == 'refs/heads/master' && needs.pcapi-init-job.outputs.pro-changed == 'true' }}
uses: ./.github/workflows/dev_on_workflow_deploy_storybook.yml
deploy-maintenance-site:
name: "Deploy maintenance site"
needs: check-folders-changes
if: |
always() &&
github.ref == 'refs/heads/master' &&
needs.check-folders-changes.outputs.maintenance-site-changed == 'true'
uses: ./.github/workflows/dev_on_workflow_deploy_maintenance_site.yml
secrets:
GCP_EHP_SERVICE_ACCOUNT: ${{ secrets.GCP_EHP_SERVICE_ACCOUNT }}
GCP_EHP_WORKLOAD_IDENTITY_PROVIDER: ${{ secrets.GCP_EHP_WORKLOAD_IDENTITY_PROVIDER }}
ping-data-team-on-slack:
name: "Ping data team on slack"
needs: check-folders-changes
if: |
always() &&
github.ref == 'refs/heads/master' &&
needs.check-folders-changes.outputs.db-migrations-changed == 'true'
uses: ./.github/workflows/dev_on_workflow_ping_data_team.yml
secrets:
GCP_EHP_SERVICE_ACCOUNT: ${{ secrets.GCP_EHP_SERVICE_ACCOUNT }}
GCP_EHP_WORKLOAD_IDENTITY_PROVIDER: ${{ secrets.GCP_EHP_WORKLOAD_IDENTITY_PROVIDER }}
tag-rc:
runs-on: ubuntu-latest
needs:
- test-api
- test-api-documentation
- test-pro
if: always()
env:
GIT_CONFIG_EMAIL: [email protected]
GIT_CONFIG_NAME: ${{ github.actor }}
steps:
- name: Checkout ref
uses: actions/checkout@v6
- name: Configure git author
run: |
git config --global user.email "$GIT_CONFIG_EMAIL"
git config --global user.name "$GIT_CONFIG_NAME"
- name: Vérifier résultats des tests
if: ${{ contains(needs.*.result, 'failure') || !contains(needs.*.result, 'success') }}
run: |
echo "Some tests have not run successfully, do not tag an RC on it"
- name: Tests tous valides, pose de tag
if: ${{ !contains(needs.*.result, 'failure') && contains(needs.*.result, 'success') }}
run: |
git tag -f rc
git push origin rc --force