-
Notifications
You must be signed in to change notification settings - Fork 0
193 lines (161 loc) · 6.09 KB
/
ci.yml
File metadata and controls
193 lines (161 loc) · 6.09 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
name: CI
on:
pull_request:
branches: [ main ]
paths:
- 'cli/**'
- '.github/workflows/ci.yml'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
defaults:
run:
working-directory: cli
env:
GO_VERSION: '1.26.1'
jobs:
preflight:
name: Preflight Checks
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: Set up Go
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5
with:
go-version: '${{ env.GO_VERSION }}'
cache: true
cache-dependency-path: cli/go.sum
- name: Cache Go tools
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v4
with:
path: ~/go/bin
key: go-tools-${{ runner.os }}-${{ env.GO_VERSION }}
- name: Install Mage
run: go install github.com/magefile/mage@latest
- name: Install golangci-lint
run: go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest
- name: Install staticcheck
run: go install honnef.co/go/tools/cmd/staticcheck@latest
- name: Install gosec
run: go install github.com/securego/gosec/v2/cmd/gosec@latest
- name: Install govulncheck
run: go install golang.org/x/vuln/cmd/govulncheck@latest
- name: Install Azure Developer CLI (azd)
run: curl -fsSL https://aka.ms/install-azd.sh | bash
- name: Run preflight checks
run: mage preflight
test:
name: Test
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- name: Checkout code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: Set up Go
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5
with:
go-version: '${{ env.GO_VERSION }}'
cache: true
cache-dependency-path: cli/go.sum
- name: Run tests
shell: bash
run: |
mkdir -p ../coverage
# Exclude tests/test-tool (it's a standalone main package with no tests)
PACKAGES=$(go list ./... | grep -v '/tests/test-tool')
# Race detector not supported on macOS without additional setup
if [ "${{ matrix.os }}" = "macos-latest" ]; then
go test -short -v -coverprofile=../coverage/coverage.out $PACKAGES
else
go test -short -v -race -coverprofile=../coverage/coverage.out $PACKAGES
fi
- name: Upload coverage to Codecov
if: github.repository == 'jongio/azd-exec'
uses: codecov/codecov-action@1af58845a975a7985b0beb0cbe6fbbb71a41dbad # v5.5.3
with:
file: coverage/coverage.out
flags: unittests
name: codecov-${{ matrix.os }}-go-${{ env.GO_VERSION }}
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
verbose: true
- name: Generate coverage report
if: matrix.os == 'ubuntu-latest' && github.event_name == 'pull_request'
run: |
go tool cover -func=../coverage/coverage.out -o=../coverage/coverage.txt
echo "## Code Coverage Report" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
cat ../coverage/coverage.txt | tail -n 20 >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
# Calculate total coverage
COVERAGE=$(go tool cover -func=../coverage/coverage.out | grep total | awk '{print $3}')
echo "**Total Coverage: $COVERAGE**" >> $GITHUB_STEP_SUMMARY
- name: Set up Go
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5
with:
go-version: '${{ env.GO_VERSION }}'
cache: true
cache-dependency-path: cli/go.sum
- name: Build for multiple platforms
run: |
mkdir -p bin/windows-amd64 bin/linux-amd64 bin/darwin-amd64 bin/darwin-arm64
GOOS=windows GOARCH=amd64 go build -o bin/windows-amd64/exec.exe ./src/cmd/exec
GOOS=linux GOARCH=amd64 go build -o bin/linux-amd64/exec ./src/cmd/exec
GOOS=darwin GOARCH=amd64 go build -o bin/darwin-amd64/exec ./src/cmd/exec
GOOS=darwin GOARCH=arm64 go build -o bin/darwin-arm64/exec ./src/cmd/exec
- name: Upload artifacts
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: binaries
path: cli/bin/
integration:
name: Integration Tests
runs-on: ${{ matrix.os }}
timeout-minutes: 30
needs: [preflight, test]
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- name: Checkout code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: Set up Go
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5
with:
go-version: '${{ env.GO_VERSION }}'
cache: true
cache-dependency-path: cli/go.sum
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: '3.11'
- name: Run port manager integration tests
shell: bash
timeout-minutes: 8
run: |
go test -v -tags=integration -timeout=6m ./src/internal/executor/...
env:
CI: true
- name: Run E2E integration tests
shell: bash
timeout-minutes: 15
run: |
go test -v -tags=integration -timeout=10m ./src/cmd/exec/commands/...
env:
CI: true
- name: Upload test logs on failure
if: failure()
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: integration-test-logs-${{ matrix.os }}
path: |
cli/tests/projects/**/*.log
cli/.azure/**/*.log
if-no-files-found: ignore