Cypress evidence integration example #4
This file contains hidden or 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: "Cypress evidence integration example" | |
| on: | |
| workflow_dispatch: | |
| permissions: | |
| id-token: write | |
| contents: read | |
| actions: read | |
| jobs: | |
| package-docker-image-with-cypress-evidence: | |
| runs-on: ubuntu-latest | |
| env: | |
| REGISTRY_URL: ${{ vars.JF_URL }} | |
| REPO_NAME: 'docker-cypress-repo' | |
| IMAGE_NAME: 'docker-cypress-image' | |
| TAG_NAME: ${{ github.run_number }} | |
| BUILD_NAME: 'cypress-docker-build' | |
| BUILD_NUMBER: ${{ github.run_number }} | |
| ATTACH_OPTIONAL_MARKDOWN_TO_EVIDENCE: true | |
| UPLOAD_CYPRESS_REPORT_TO_CLOUD: false | |
| steps: | |
| - uses: jfrog/setup-jfrog-cli@v4 | |
| name: jfrog-cli setup | |
| env: | |
| JF_URL: ${{ vars.ARTIFACTORY_URL }} | |
| JF_ACCESS_TOKEN: ${{ secrets.JF_ACCESS_TOKEN }} | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| sparse-checkout: | | |
| examples/cypress-test-reports-example/** | |
| sparse-checkout-cone-mode: false | |
| - name: Build and publish Docker image | |
| run: | | |
| docker build . --file ./examples/cypress-test-reports-example/Dockerfile --tag $REGISTRY_URL/$REPO_NAME/$IMAGE_NAME:$TAG_NAME | |
| jf rt docker-push $REGISTRY_URL/$REPO_NAME/$IMAGE_NAME:$TAG_NAME $REPO_NAME --build-name=$BUILD_NAME --build-number=$BUILD_NUMBER | |
| jf rt build-publish $BUILD_NAME $BUILD_NUMBER | |
| # Steps to run Cypress tests and converge to a single report | |
| - name: Cypress run | |
| uses: cypress-io/github-action@v6 | |
| with: | |
| record: ${{ env.UPLOAD_CYPRESS_REPORT_TO_CLOUD == 'true' }} | |
| install: true | |
| install-command: npm install | |
| start: npm run start | |
| quiet: true | |
| wait-on: 'http://localhost:3000/app.html' | |
| wait-on-timeout: 120 | |
| working-directory: examples/cypress-test-reports-example | |
| env: | |
| CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} | |
| continue-on-error: true | |
| - name: Merge Cypress results | |
| run: npm run merge-results | |
| working-directory: examples/cypress-test-reports-example | |
| # This is an optional step to generate a markdown report | |
| - name: Generate optional markdown report | |
| if: env.ATTACH_OPTIONAL_MARKDOWN_TO_EVIDENCE == 'true' | |
| run: npm run generate:md | |
| working-directory: examples/cypress-test-reports-example | |
| env: | |
| IMAGE_REF: ${{ env.REGISTRY_URL }}/${{ env.REPO_NAME }}/${{ env.IMAGE_NAME }}:${{ env.TAG_NAME }} | |
| #Steps to attach evidence to the package | |
| - name: Attach evidence to the package | |
| working-directory: examples/cypress-test-reports-example | |
| run: | | |
| jf evd create \ | |
| --package-name $IMAGE_NAME \ | |
| --package-version $TAG_NAME \ | |
| --package-repo-name $REPO_NAME \ | |
| --key "${{ secrets.PRIVATE_KEY }}" \ | |
| --key-alias "${{ secrets.PRIVATE_KEY_ALIAS }}" \ | |
| --predicate "reports/overall-report.json" \ | |
| --predicate-type "http://cypress.io/test-results/v1" \ | |
| ${{ env.ATTACH_OPTIONAL_MARKDOWN_TO_EVIDENCE == 'true' && '--markdown "reports/cypress-results.md"' || '' }} |