|
6 | 6 | paths: |
7 | 7 | - 'cli/**' |
8 | 8 | - '.github/workflows/ci.yml' |
9 | | - - '.github/workflows/shared-checks.yml' |
10 | 9 | workflow_dispatch: |
11 | 10 |
|
| 11 | +defaults: |
| 12 | + run: |
| 13 | + working-directory: cli |
| 14 | + |
12 | 15 | 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 |
17 | 168 |
|
18 | 169 | build: |
19 | 170 | name: Build |
20 | 171 | runs-on: ubuntu-latest |
21 | | - needs: checks |
| 172 | + needs: [preflight, test, lint] |
22 | 173 |
|
23 | 174 | defaults: |
24 | 175 | run: |
|
0 commit comments