-
Notifications
You must be signed in to change notification settings - Fork 63
108 lines (103 loc) · 4.18 KB
/
e2e_testing.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
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 }}