-
Notifications
You must be signed in to change notification settings - Fork 10
138 lines (124 loc) · 3.85 KB
/
it-test.yml
File metadata and controls
138 lines (124 loc) · 3.85 KB
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
name: plugin it-test
permissions:
contents: write
on:
push:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # Needed for git history
- name: Set up Go
uses: actions/setup-go@v4
- name: Build CLI for all platforms
run: make build-all
- name: Upload CLI binaries
uses: actions/upload-artifact@v4
with:
name: cli-binaries
path: |
cli-v2-linux
cli-v2.exe
cli-v2-macos
test:
needs: build
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
fail-fast: false
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Needed for git history
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.21'
cache: true
- name: Download CLI binaries
uses: actions/download-artifact@v4
with:
name: cli-binaries
path: .
- name: Select correct binary
shell: bash
run: |
if [ "${{ matrix.os }}" = "windows-latest" ]; then
# Keep the .exe extension for Windows
echo "Using Windows binary with .exe extension"
elif [ "${{ matrix.os }}" = "macos-latest" ]; then
mv cli-v2-macos cli-v2
else
mv cli-v2-linux cli-v2
fi
- name: Make binary executable
if: matrix.os != 'windows-latest'
run: chmod +x cli-v2
- name: Run init tests on Windows native
if: matrix.os == 'windows-latest'
id: run_init_tests_windows
continue-on-error: true
shell: pwsh
run: |
$ErrorActionPreference = "Stop"
& ./integration-tests/run.ps1
if ($LASTEXITCODE -ne 0) {
Write-Error "Integration tests failed with exit code $LASTEXITCODE"
exit $LASTEXITCODE
}
env:
CODACY_API_TOKEN: ${{ secrets.CODACY_API_TOKEN }}
- name: Run init tests on Unix
if: matrix.os != 'windows-latest'
id: run_init_tests_unix
continue-on-error: true
shell: bash
env:
CODACY_API_TOKEN: ${{ secrets.CODACY_API_TOKEN }}
run: |
chmod +x integration-tests/run.sh
./integration-tests/run.sh
- name: Run tool tests on Unix
if: matrix.os != 'windows-latest'
uses: ./.github/actions/tool-tests
with:
shell: bash
- name: Run tool tests on Windows WSL
if: matrix.os == 'windows-latest'
uses: ./.github/actions/tool-tests
with:
shell: wsl
- name: Check test results
if: always()
shell: bash
run: |
# Check init tests
if [ "${{ matrix.os }}" = "windows-latest" ]; then
if [ "${{ steps.run_init_tests_windows.outcome }}" = "failure" ]; then
echo "::error::Windows init tests failed"
FAILED=true
fi
if [ "${{ steps.run_tests_windows.outcome }}" = "failure" ]; then
echo "::error::Windows tool tests failed"
FAILED=true
fi
else
if [ "${{ steps.run_init_tests_unix.outcome }}" = "failure" ]; then
echo "::error::Unix init tests failed"
FAILED=true
fi
if [ "${{ steps.run_tests_unix.outcome }}" = "failure" ]; then
echo "::error::Unix tool tests failed"
FAILED=true
fi
fi
# Fail if any tests failed
if [ "${FAILED:-false}" = "true" ]; then
echo "Some tests failed. Please check the logs above for details."
exit 1
fi