generated from hashicorp/packer-plugin-scaffolding
-
Notifications
You must be signed in to change notification settings - Fork 15
91 lines (75 loc) · 2.69 KB
/
integration-unit-test.yml
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
name: Integration and Unit Tests
on:
push:
branches:
- 'main'
- 'dev'
env:
REPORT_FILENAME:
jobs:
integration-and-unit-tests:
runs-on: ubuntu-latest
if: github.event_name == 'push' && (github.event.ref == 'refs/heads/main' || github.event.ref == 'refs/heads/dev')
env:
EXIT_STATUS: 0
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ needs.get-go-version.outputs.go-version }}
- name: Install go-junit-report
run: go install github.com/jstemmer/go-junit-report/v2@latest
- name: Set report filename
id: set-report-filename
run: echo "REPORT_FILENAME=$(date +'%Y%m%d%H%M')_packer_test_report.xml" >> $GITHUB_ENV
- name: Run integration and unit tests
run: |
echo "Testing with Go ${{ needs.get-go-version.outputs.go-version }}"
make test | go-junit-report -set-exit-code -iocopy -out "$REPORT_FILENAME"
env:
LINODE_TOKEN: ${{ secrets.LINODE_TOKEN }}
- name: Upload test report as artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: test-report-file
path: "${{ env.REPORT_FILENAME }}"
process-upload-report:
runs-on: ubuntu-latest
needs:
- integration-and-unit-tests
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: 'recursive'
- name: Download test report
uses: actions/download-artifact@v4
with:
name: test-report-file
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install Python dependencies
run: pip3 install requests wheel boto3
- name: Set release version env
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Add additional information to XML report
run: |
filename=$(ls | grep -E '^[0-9]{12}_packer_test_report\.xml$')
python tod_scripts/add_to_xml_test_report.py \
--branch_name "${{ env.RELEASE_VERSION }}" \
--gha_run_id "$GITHUB_RUN_ID" \
--gha_run_number "$GITHUB_RUN_NUMBER" \
--xmlfile "${filename}"
- name: Upload test results to the bucket
run: |
filename=$(ls | grep -E '^[0-9]{12}_packer_test_report\.xml$')
python3 tod_scripts/test_report_upload_script.py "${filename}"
env:
LINODE_CLI_OBJ_ACCESS_KEY: ${{ secrets.LINODE_CLI_OBJ_ACCESS_KEY }}
LINODE_CLI_OBJ_SECRET_KEY: ${{ secrets.LINODE_CLI_OBJ_SECRET_KEY }}