Skip to content

Commit

Permalink
(BSR)[PRO] commit to be removed only for triggering the job
Browse files Browse the repository at this point in the history
  • Loading branch information
mleroy-pass committed Feb 6, 2025
1 parent 2ba3c7f commit d60eacc
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 53 deletions.
147 changes: 95 additions & 52 deletions .github/workflows/dev_on_workflow_tests_pro_e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,62 @@ defaults:
working-directory: pro

jobs:
tests-pro-e2e-tests:
install:
name: "E2E tests and notifications"
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4

- uses: technote-space/workflow-conclusion-action@v3

- uses: actions/setup-node@v4
with:
node-version-file: "pro/.nvmrc"

- name: install
run: yarn install --immutable

- name: "Build vite application"
run: yarn build:development

- name: Save build folder
uses: actions/upload-artifact@v4
with:
name: build
if-no-files-found: error
path: pro/build

# Doc : https://github.com/cypress-io/github-action

# - name: "Remove Cypress videos from Allure results"
# run: rm -rf ../allure-results/*.mp4

# - name: "Upload Allure results for pro E2E tests"
# uses: actions/upload-artifact@v4
# with:
# name: allure-results-pro-e2e
# path: allure-results

cypress-run:
runs-on: ubuntu-24.04
needs: install
strategy:
# when one test fails, DO NOT cancel the other
# containers, because this will kill Cypress processes
# leaving Cypress Cloud hanging ...
# https://github.com/cypress-io/github-action/issues/48
# don't fail the entire matrix on failure
fail-fast: false
matrix:
# run copies of the current job in parallel
containers: [1, 2, 3, 4, 5]
steps:
- uses: actions/checkout@v4.2.2
- uses: technote-space/workflow-conclusion-action@v3
- name: Checkout
uses: actions/checkout@v4

- name: "Authentification to Google"
uses: "google-github-actions/auth@v2"
with:
workload_identity_provider: ${{ secrets.GCP_EHP_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.GCP_EHP_SERVICE_ACCOUNT }}

- name: "Get Secret"
id: secrets
uses: "google-github-actions/get-secretmanager-secrets@v2"
Expand All @@ -57,44 +93,29 @@ jobs:
ARTIFACT_REGISTRY_SERVICE_ACCOUNT:passculture-metier-ehp/passculture-main-artifact-registry-service-account
CYPRESS_CLOUD_RECORD_KEY:passculture-metier-ehp/e2e-tests-pro-cypress-cloud-record-key
CYPRESS_CLOUD_PROJECT_ID:passculture-metier-ehp/e2e-tests-pro-cypress-cloud-project-id
- name: "OpenID Connect Authentication"
id: openid-auth
uses: "google-github-actions/auth@v2"
with:
create_credentials_file: false
token_format: "access_token"
workload_identity_provider: ${{ steps.secrets.outputs.ARTIFACT_REGISTRY_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ steps.secrets.outputs.ARTIFACT_REGISTRY_SERVICE_ACCOUNT }}
- name: "Docker login"
id: docker-login
uses: "docker/login-action@v3"
with:
registry: "europe-west1-docker.pkg.dev"
username: "oauth2accesstoken"
password: "${{ steps.openid-auth.outputs.access_token }}"
- name: "Compute docker image name:tag"
id: compute-image-name
run: |
echo "image_name=${{ env.registry }}/${{ inputs.image }}:${{ inputs.tag }}" | tee -a ${GITHUB_OUTPUT}
echo "::notice:: Running e2e-tests with ${{ env.registry }}/${{ inputs.image }}:${{ inputs.tag }}"
- name: "Download artifact"
if: ${{ inputs.tag != 'latest' }}
uses: actions/download-artifact@v4
with:
name: ${{ inputs.image }}-${{ inputs.tag }}.tar
path: ${{ runner.temp }}
# - name: "Download artifact"
# if: ${{ inputs.tag != 'latest' }}
# uses: actions/download-artifact@v4
# with:
# name: ${{ inputs.image }}-${{ inputs.tag }}.tar
# path: ${{ runner.temp }}

- uses: actions/setup-node@v4
with:
node-version-file: "pro/.nvmrc"

- uses: KengoTODA/actions-setup-docker-compose@v1
with:
version: "2.23.3"

- name: "Fix local permissions"
run: sudo chown -R $PCAPI_UID:$PCAPI_GID .
working-directory: api
env:
PCAPI_UID: 1000
PCAPI_GID: 1000

- name: "Cache the node_modules"
id: "yarn-modules-cache"
uses: pass-culture-github-actions/cache@v1.0.0
Expand All @@ -107,11 +128,35 @@ jobs:
key: v1-yarn-pro-cypress-dependency-cache-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
v1-yarn-pro-cypress-dependency-cache-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
- run: yarn install --immutable
- name: "OpenID Connect Authentication"
id: openid-auth
uses: "google-github-actions/auth@v2"
with:
create_credentials_file: false
token_format: "access_token"
workload_identity_provider: ${{ steps.secrets.outputs.ARTIFACT_REGISTRY_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ steps.secrets.outputs.ARTIFACT_REGISTRY_SERVICE_ACCOUNT }}

- name: "Docker login"
id: docker-login
uses: "docker/login-action@v3"
with:
registry: "europe-west1-docker.pkg.dev"
username: "oauth2accesstoken"
password: "${{ steps.openid-auth.outputs.access_token }}"
- name: "Compute docker image name:tag"
id: compute-image-name
run: |
echo "image_name=${{ env.registry }}/${{ inputs.image }}:${{ inputs.tag }}" | tee -a ${GITHUB_OUTPUT}
echo "::notice:: Running e2e-tests with ${{ env.registry }}/${{ inputs.image }}:${{ inputs.tag }}"
- name: "Run postgres and redis server"
run: docker-compose -f ../docker-compose-backend.yml up postgres redis -d

- name: "Set up Cloud SDK"
uses: "google-github-actions/setup-gcloud@v2"

- name: "Run API server"
run: |
if [ "${{ inputs.tag }}" != "latest" ]; then
Expand All @@ -136,18 +181,17 @@ jobs:
with:
resource: http://localhost:5001/health/api
timeout: 120000
- name: "Build vite application"
run: yarn build:development
- name: "Serve vite preview"
run: yarn serve &
# Using wait-on does not work well for this service, we use curl
- name: "Wait for front-end to listen"
run: |
timeout 300 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:3001)" != "200" ]]; do sleep 5; done' || false
# Doc : https://github.com/cypress-io/github-action

- name: Download the build folder
uses: actions/download-artifact@v4
with:
name: build

- name: "Cypress run"
uses: cypress-io/github-action@v6
with:
start: yarn run start
parallel: true
wait-on: "http://localhost:5001/health/api,http://localhost:5001/health/database"
wait-on-timeout: 600
working-directory: pro
Expand All @@ -159,31 +203,30 @@ jobs:
env:
CYPRESS_RECORD_KEY: ${{ steps.secrets.outputs.CYPRESS_CLOUD_RECORD_KEY }}
CYPRESS_PROJECT_ID: ${{ steps.secrets.outputs.CYPRESS_CLOUD_PROJECT_ID }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# - name: "Remove Cypress videos from Allure results"
# run: rm -rf ../allure-results/*.mp4
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}git st

# - name: "Upload Allure results for pro E2E tests"
# uses: actions/upload-artifact@v4
# with:
# name: allure-results-pro-e2e
# path: allure-results
# Using wait-on does not work well for this service, we use curl
- name: "Wait for front-end to listen"
run: |
timeout 300 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:3001)" != "200" ]]; do sleep 5; done' || false
- name: "Move cypress videos"
if: always() && failure() && github.ref != 'refs/heads/master' # useless on master bc Cypress Cloud
run: |
mkdir -p cypress/videos/${{ github.ref }}/${{ github.sha }} && \
mv cypress/videos/*.mp4 cypress/videos/${{ github.ref }}/${{ github.sha }}/
- name: "Archive E2E results"
if: always() && failure() && github.ref != 'refs/heads/master' # useless on master bc Cypress Cloud
uses: google-github-actions/upload-cloud-storage@v2
with:
path: "pro/cypress/videos"
destination: "${{ inputs.CACHE_BUCKET_NAME }}/pro/cypress/videos/e2e-artifacts"

- name: "Show pcapi log when it fails"
if: failure()
run: docker logs pc-api

- name: "Post to a Slack channel"
if: always() && failure() && github.ref == 'refs/heads/master'
uses: slackapi/slack-github-action@v1.27.0
Expand Down
2 changes: 1 addition & 1 deletion pro/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pass-culture-pro
# pass-culture-pro pass-culture-pro

C'est la version (browser) de l’application PRO frontend du pass Culture. Ce repo contient également [un storybook](https://pass-culture.github.io/pass-culture-main/) des éléments graphiques

Expand Down

0 comments on commit d60eacc

Please sign in to comment.