forked from novasamatech/nova-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
139 lines (117 loc) · 4.19 KB
/
run_integration_tests.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
name: Integration tests for config
on:
pull_request:
paths:
- "chains/**"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
BODY_FILE: comment-body.txt
permissions:
pull-requests: write
statuses: write
jobs:
prepare-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
current: ${{ steps.current.outputs.any_changed }}
previous: ${{ steps.previous.outputs.any_changed }}
name: Check which version was changed
steps:
- name: Checkout
uses: actions/checkout@v3
- name: 🛠 Set up actual paths
uses: ./.github/workflows/setup-path
- name: Was chains.json changed?
id: current
uses: tj-actions/[email protected]
with:
files: |
${{ env.CHAINS_JSON_PATH }}
- name: Was previous chains.json changed?
id: previous
uses: tj-actions/[email protected]
with:
files: |
${{ env.PREVIOUS_CHAINS_JSON_PATH }}
- name: Generate test paths
run: |
if [[ "${{ steps.current.outputs.any_changed }}" == 'true' ]]; then
echo "TEST_PATHS=${{ env.CHAINS_JSON_PATH }}" >> $GITHUB_ENV
fi
if [[ "${{ steps.previous.outputs.any_changed }}" == 'true' ]]; then
if [[ -n "${{ env.TEST_PATHS }}" ]]; then
echo "TEST_PATHS=${{ env.TEST_PATHS }},${{ env.PREVIOUS_CHAINS_JSON_PATH }}" >> $GITHUB_ENV
else
echo "TEST_PATHS=${{ env.PREVIOUS_CHAINS_JSON_PATH }}" >> $GITHUB_ENV
fi
fi
- name: Set matrix
id: set-matrix
run: |
echo "::set-output name=matrix::{\"test_path\": [\"${TEST_PATHS}\"]}"
integration-tests:
name: ${{ matrix.test_path }}
runs-on: ubuntu-latest
needs: prepare-matrix
if: always() && (needs.prepare-matrix.outputs.current == 'true' || needs.prepare-matrix.outputs.previous == 'true')
strategy:
fail-fast: false
matrix:
test_path: ${{fromJson(needs.prepare-matrix.outputs.matrix).test_path}}
steps:
- uses: actions/checkout@v4
- name: Set up actual paths
uses: ./.github/workflows/setup-path
- name: Install dependencies
run: make init
- name: Run test
run: CHAINS_JSON_PATH=${{ matrix.test_path }} make test-core
continue-on-error: true
- name: Surface failing tests
if: always()
uses: pmeier/pytest-results-action@main
with:
path: test-results.xml
process-results:
runs-on: ubuntu-latest
needs: integration-tests
if: always() && (needs.integration-tests.result == 'failure' || needs.integration-tests.result == 'success')
steps:
- name: Save URLs to file
run: echo "🧪 Test results" > ${{ env.BODY_FILE }}
- name: Install jq
run: sudo apt-get install jq
- name: Get job IDs and create URLs
id: get-job-ids
run: |
url="https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/jobs"
response=$(curl --silent --location "$url")
job_ids=$(echo "$response" | jq '.jobs[1:-1][] | .id')
urls=""
for id in $job_ids
do
echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/attempts/1#summary-$id" >> ${{ env.BODY_FILE }}
done
- name: Find Comment
uses: peter-evans/find-comment@v2
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: 🧪 Test results
- name: Create comment
if: steps.fc.outputs.comment-id == ''
uses: peter-evans/create-or-update-comment@v2
with:
issue-number: ${{ github.event.pull_request.number }}
body-file: ${{ env.BODY_FILE }}
- name: Update comment
if: steps.fc.outputs.comment-id != ''
uses: peter-evans/create-or-update-comment@v2
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
body-file: ${{ env.BODY_FILE }}
edit-mode: replace