Skip to content

Commit dbadfee

Browse files
committed
ci: refactor CI workflows to consolidate checks and improve structure
1 parent 2f7b676 commit dbadfee

File tree

3 files changed

+291
-174
lines changed

3 files changed

+291
-174
lines changed

.github/workflows/ci.yml

Lines changed: 157 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,170 @@ on:
66
paths:
77
- 'cli/**'
88
- '.github/workflows/ci.yml'
9-
- '.github/workflows/shared-checks.yml'
109
workflow_dispatch:
1110

11+
defaults:
12+
run:
13+
working-directory: cli
14+
1215
jobs:
13-
checks:
14-
name: Run Checks
15-
uses: ./.github/workflows/shared-checks.yml
16-
secrets: inherit
16+
preflight:
17+
name: Preflight Checks
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
24+
- name: Set up Go
25+
uses: actions/setup-go@v5
26+
with:
27+
go-version: '1.25'
28+
cache-dependency-path: cli/go.sum
29+
30+
- name: Set up Node.js
31+
uses: actions/setup-node@v4
32+
with:
33+
node-version: '20'
34+
cache: 'npm'
35+
cache-dependency-path: cli/dashboard/package.json
36+
37+
- name: Install Mage
38+
run: go install github.com/magefile/mage@latest
39+
40+
- name: Install golangci-lint
41+
run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
42+
43+
- name: Install gosec
44+
run: go install github.com/securego/gosec/v2/cmd/gosec@latest
45+
46+
- name: Run preflight checks
47+
run: mage preflight
48+
49+
test:
50+
name: Test
51+
runs-on: ${{ matrix.os }}
52+
strategy:
53+
matrix:
54+
os: [ubuntu-latest, windows-latest, macos-latest]
55+
go-version: ['1.25']
56+
57+
steps:
58+
- name: Checkout code
59+
uses: actions/checkout@v4
60+
61+
- name: Set up Go
62+
uses: actions/setup-go@v5
63+
with:
64+
go-version: ${{ matrix.go-version }}
65+
cache-dependency-path: cli/go.sum
66+
67+
- name: Set up Node.js
68+
uses: actions/setup-node@v4
69+
with:
70+
node-version: '20'
71+
cache: 'npm'
72+
cache-dependency-path: cli/dashboard/package.json
73+
74+
- name: Build dashboard
75+
run: |
76+
cd dashboard
77+
npm install
78+
npm run build
79+
cd ..
80+
81+
- name: Install Aspire CLI
82+
shell: pwsh
83+
run: |
84+
$version = "9.5.2"
85+
if (dotnet tool list --global | Select-String -Pattern "^aspire.cli\s") {
86+
dotnet tool update --global aspire.cli --version $version
87+
}
88+
else {
89+
dotnet tool install --global aspire.cli --version $version
90+
}
91+
if ($IsWindows) {
92+
$toolPath = "$env:USERPROFILE\.dotnet\tools"
93+
}
94+
else {
95+
$toolPath = "$env:HOME/.dotnet/tools"
96+
}
97+
if (-not (Test-Path $toolPath)) {
98+
throw "Dotnet tool path not found: $toolPath"
99+
}
100+
$toolPath | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
101+
102+
- name: Download dependencies
103+
run: go mod download
104+
105+
- name: Run tests
106+
shell: bash
107+
run: |
108+
mkdir -p ../coverage
109+
go test -short -v -race -coverprofile=../coverage/coverage.out ./...
110+
111+
- name: Upload coverage to Codecov
112+
if: github.repository == 'jongio/azd-app'
113+
uses: codecov/codecov-action@v4
114+
with:
115+
file: coverage/coverage.out
116+
flags: unittests
117+
name: codecov-${{ matrix.os }}-go-${{ matrix.go-version }}
118+
token: ${{ secrets.CODECOV_TOKEN }}
119+
fail_ci_if_error: false
120+
verbose: true
121+
122+
- name: Generate coverage report
123+
if: matrix.os == 'ubuntu-latest' && github.event_name == 'pull_request'
124+
run: |
125+
go tool cover -func=../coverage/coverage.out -o=../coverage/coverage.txt
126+
echo "## Code Coverage Report" >> $GITHUB_STEP_SUMMARY
127+
echo '```' >> $GITHUB_STEP_SUMMARY
128+
cat ../coverage/coverage.txt | tail -n 20 >> $GITHUB_STEP_SUMMARY
129+
echo '```' >> $GITHUB_STEP_SUMMARY
130+
131+
# Calculate total coverage
132+
COVERAGE=$(go tool cover -func=../coverage/coverage.out | grep total | awk '{print $3}')
133+
echo "**Total Coverage: $COVERAGE**" >> $GITHUB_STEP_SUMMARY
134+
135+
lint:
136+
name: Lint
137+
runs-on: ubuntu-latest
138+
139+
steps:
140+
- name: Checkout code
141+
uses: actions/checkout@v4
142+
143+
- name: Set up Go
144+
uses: actions/setup-go@v5
145+
with:
146+
go-version: '1.25'
147+
cache-dependency-path: cli/go.sum
148+
149+
- name: Set up Node.js
150+
uses: actions/setup-node@v4
151+
with:
152+
node-version: '20'
153+
cache: 'npm'
154+
cache-dependency-path: cli/dashboard/package.json
155+
156+
- name: Build dashboard assets
157+
run: |
158+
cd dashboard
159+
npm install
160+
npm run build
161+
cd ..
162+
163+
- name: Install golangci-lint
164+
run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
165+
166+
- name: Run golangci-lint
167+
run: golangci-lint run --timeout=5m
17168

18169
build:
19170
name: Build
20171
runs-on: ubuntu-latest
21-
needs: checks
172+
needs: [preflight, test, lint]
22173

23174
defaults:
24175
run:

.github/workflows/release.yml

Lines changed: 134 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,145 @@ on:
1212
- minor
1313
- major
1414

15+
defaults:
16+
run:
17+
shell: bash
18+
working-directory: cli
19+
1520
jobs:
16-
checks:
17-
name: Run Checks
18-
uses: ./.github/workflows/shared-checks.yml
19-
secrets: inherit
21+
preflight:
22+
name: Preflight Checks
23+
runs-on: ubuntu-latest
24+
25+
steps:
26+
- name: Checkout code
27+
uses: actions/checkout@v4
28+
29+
- name: Set up Go
30+
uses: actions/setup-go@v5
31+
with:
32+
go-version: '1.25'
33+
cache-dependency-path: cli/go.sum
34+
35+
- name: Set up Node.js
36+
uses: actions/setup-node@v4
37+
with:
38+
node-version: '20'
39+
cache: 'npm'
40+
cache-dependency-path: cli/dashboard/package.json
41+
42+
- name: Install Mage
43+
run: go install github.com/magefile/mage@latest
44+
45+
- name: Install golangci-lint
46+
run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
47+
48+
- name: Install gosec
49+
run: go install github.com/securego/gosec/v2/cmd/gosec@latest
50+
51+
- name: Run preflight checks
52+
run: mage preflight
53+
54+
test:
55+
name: Test
56+
runs-on: ${{ matrix.os }}
57+
strategy:
58+
matrix:
59+
os: [ubuntu-latest, windows-latest, macos-latest]
60+
go-version: ['1.25']
61+
62+
steps:
63+
- name: Checkout code
64+
uses: actions/checkout@v4
65+
66+
- name: Set up Go
67+
uses: actions/setup-go@v5
68+
with:
69+
go-version: ${{ matrix.go-version }}
70+
cache-dependency-path: cli/go.sum
71+
72+
- name: Set up Node.js
73+
uses: actions/setup-node@v4
74+
with:
75+
node-version: '20'
76+
cache: 'npm'
77+
cache-dependency-path: cli/dashboard/package.json
78+
79+
- name: Build dashboard
80+
run: |
81+
cd dashboard
82+
npm install
83+
npm run build
84+
cd ..
85+
86+
- name: Install Aspire CLI
87+
shell: pwsh
88+
run: |
89+
$version = "9.5.2"
90+
if (dotnet tool list --global | Select-String -Pattern "^aspire.cli\s") {
91+
dotnet tool update --global aspire.cli --version $version
92+
}
93+
else {
94+
dotnet tool install --global aspire.cli --version $version
95+
}
96+
if ($IsWindows) {
97+
$toolPath = "$env:USERPROFILE\.dotnet\tools"
98+
}
99+
else {
100+
$toolPath = "$env:HOME/.dotnet/tools"
101+
}
102+
if (-not (Test-Path $toolPath)) {
103+
throw "Dotnet tool path not found: $toolPath"
104+
}
105+
$toolPath | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
106+
107+
- name: Download dependencies
108+
run: go mod download
109+
110+
- name: Run tests
111+
shell: bash
112+
run: |
113+
mkdir -p ../coverage
114+
go test -short -v -race -coverprofile=../coverage/coverage.out ./...
115+
116+
lint:
117+
name: Lint
118+
runs-on: ubuntu-latest
119+
120+
steps:
121+
- name: Checkout code
122+
uses: actions/checkout@v4
123+
124+
- name: Set up Go
125+
uses: actions/setup-go@v5
126+
with:
127+
go-version: '1.25'
128+
cache-dependency-path: cli/go.sum
129+
130+
- name: Set up Node.js
131+
uses: actions/setup-node@v4
132+
with:
133+
node-version: '20'
134+
cache: 'npm'
135+
cache-dependency-path: cli/dashboard/package.json
136+
137+
- name: Build dashboard assets
138+
run: |
139+
cd dashboard
140+
npm install
141+
npm run build
142+
cd ..
143+
144+
- name: Install golangci-lint
145+
run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
146+
147+
- name: Run golangci-lint
148+
run: golangci-lint run --timeout=5m
20149

21150
release:
22151
name: Release
23152
runs-on: ubuntu-latest
24-
needs: checks
153+
needs: [preflight, test, lint]
25154
permissions:
26155
contents: write
27156

@@ -100,7 +229,6 @@ jobs:
100229
cd ..
101230
git config user.name "github-actions[bot]"
102231
git config user.email "github-actions[bot]@users.noreply.github.com"
103-
git pull --rebase origin main
104232
git add cli/extension.yaml cli/CHANGELOG.md
105233
git commit -m "chore: bump version to $VERSION"
106234
git push

0 commit comments

Comments
 (0)