Skip to content

E2E Tests

E2E Tests #1279

Workflow file for this run

name: E2E Tests
on:
workflow_dispatch:
schedule:
- cron: "0 20 * * *"
release:
types: [ published ]
pull_request:
pull_request_target:
types: [ labeled ]
permissions:
contents: read
pull-requests: write
jobs:
install_and_run_e2e_tests:
if: ${{ github.event.pull_request.head.repo.fork == false || (github.event.pull_request.head.repo.fork == true && contains(github.event.pull_request.labels.*.name,'Approve E2E Test')) }}
runs-on: ubuntu-latest
strategy:
matrix:
include:
- scm_token: E2E_ENV_TOKEN_GITHUB
report_file_path: /tmp/gh_out.json
scm: github
test_plan: TestGitHub
extra: --org legitify-e2e,legitify-e2e-2
- scm_token: E2E_ENV_TOKEN_GITLAB
report_file_path: /tmp/gl_out.json
scm: gitlab
test_plan: TestGitLab
extra:
- scm_token: E2E_ENV_TOKEN_GITHUB
report_file_path: /tmp/gh_out.json
scm: github
test_plan: TestCLI
extra: --failed-only
- scm_token: E2E_ENV_TOKEN_GITHUB
report_file_path: /tmp/gh_out.json
scm: github
test_plan: TestCLI
extra: --namespace repository
- scm_token: E2E_ENV_TOKEN_GITHUB
report_file_path: /tmp/gh_out.json
scm: github
test_plan: TestCLI
extra: --org Legitify-E2E
- scm_token: E2E_ENV_TOKEN_GITHUB
report_file_path: /tmp/gh_out.json
scm: github
test_plan: TestCLI
extra: --repo Legitify-E2E/bad_branch_protection
steps:
- name: Checkout non-fork
if: ${{ github.event.pull_request.head.repo.fork == false }}
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # ratchet:actions/checkout@v3
- name: Checkout fork
if: ${{ github.event.pull_request.head.repo.fork == true }}
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # ratchet:actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # ratchet:actions/setup-go@v3
with:
go-version: 1.19
- name: Build
run: |
make build
- name: Run tests
run: |
./legitify analyze --output-format json --output-file ${{ matrix.report_file_path }} --scm ${{ matrix.scm }} ${{ matrix.extra }}
env:
SCM_TOKEN: ${{ secrets[matrix.scm_token] }}
- name: Run output verification
run: go test ./e2e/... -run ${{ matrix.test_plan }} --report_path=${{ matrix.report_file_path }} --execution_args '${{ matrix.extra }}'
- name: Upload error log
if: always()
uses: actions/upload-artifact@83fd05a356d7e2593de66fc9913b3002723633cb
with:
name: error-log-${{ matrix.scm }}
path: error.log
- name: Upload analyze output
if: always()
uses: actions/upload-artifact@83fd05a356d7e2593de66fc9913b3002723633cb
with:
name: ${{ matrix.scm }}_analyze_output.json
path: ${{ matrix.report_file_path }}
- name: Notify Slack
uses: rtCamp/action-slack-notify@28e8b353eabda5998a2e1203aed33c5999944779
if: failure()
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_HOOKS_LEGITIFY_ALERTS }}
SLACK_CHANNEL: legitify-e2e
SLACK_COLOR: ${{ job.status }}
SLACK_MESSAGE: E2E Tests failed - ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
SLACK_TITLE: "Legitify periodic E2E test failed"
remove_e2e_label:
if: ${{ always() && (github.event.pull_request.head.repo.fork == true && contains(github.event.pull_request.labels.*.name,'Approve E2E Test')) }}
needs: install_and_run_e2e_tests
runs-on: ubuntu-latest
steps:
- name: Remove E2E Label
run: |
gh api --method DELETE -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" repos/${{ github.repository }}/issues/${{ github.event.number }}/labels/${{ 'Approve%20E2E%20Test' }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}