github.com/argoproj/argo-cd/v2@v2.10.9/.github/workflows/ci-build.yaml (about) 1 name: Integration tests 2 on: 3 push: 4 branches: 5 - 'master' 6 - 'release-*' 7 - '!release-1.4' 8 - '!release-1.5' 9 pull_request: 10 branches: 11 - 'master' 12 - 'release-*' 13 14 env: 15 # Golang version to use across CI steps 16 GOLANG_VERSION: '1.21' 17 18 concurrency: 19 group: ${{ github.workflow }}-${{ github.ref }} 20 cancel-in-progress: true 21 22 permissions: 23 contents: read 24 25 jobs: 26 check-go: 27 name: Ensure Go modules synchronicity 28 runs-on: ubuntu-22.04 29 steps: 30 - name: Checkout code 31 uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 32 - name: Setup Golang 33 uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.0.0 34 with: 35 go-version: ${{ env.GOLANG_VERSION }} 36 - name: Download all Go modules 37 run: | 38 go mod download 39 - name: Check for tidyness of go.mod and go.sum 40 run: | 41 go mod tidy 42 git diff --exit-code -- . 43 44 build-go: 45 name: Build & cache Go code 46 runs-on: ubuntu-22.04 47 steps: 48 - name: Checkout code 49 uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 50 - name: Setup Golang 51 uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.0.0 52 with: 53 go-version: ${{ env.GOLANG_VERSION }} 54 - name: Restore go build cache 55 uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2 56 with: 57 path: ~/.cache/go-build 58 key: ${{ runner.os }}-go-build-v1-${{ github.run_id }} 59 - name: Download all Go modules 60 run: | 61 go mod download 62 - name: Compile all packages 63 run: make build-local 64 65 lint-go: 66 permissions: 67 contents: read # for actions/checkout to fetch code 68 pull-requests: read # for golangci/golangci-lint-action to fetch pull requests 69 name: Lint Go code 70 runs-on: ubuntu-22.04 71 steps: 72 - name: Checkout code 73 uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 74 - name: Setup Golang 75 uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.0.0 76 with: 77 go-version: ${{ env.GOLANG_VERSION }} 78 - name: Run golangci-lint 79 uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3.7.0 80 with: 81 version: v1.54.0 82 args: --enable gofmt --timeout 10m --exclude SA5011 --verbose --max-issues-per-linter 0 --max-same-issues 0 83 84 test-go: 85 name: Run unit tests for Go packages 86 runs-on: ubuntu-22.04 87 needs: 88 - build-go 89 env: 90 GITHUB_TOKEN: ${{ secrets.E2E_TEST_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} 91 GITLAB_TOKEN: ${{ secrets.E2E_TEST_GITLAB_TOKEN }} 92 steps: 93 - name: Create checkout directory 94 run: mkdir -p ~/go/src/github.com/argoproj 95 - name: Checkout code 96 uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 97 - name: Create symlink in GOPATH 98 run: ln -s $(pwd) ~/go/src/github.com/argoproj/argo-cd 99 - name: Setup Golang 100 uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.0.0 101 with: 102 go-version: ${{ env.GOLANG_VERSION }} 103 - name: Install required packages 104 run: | 105 sudo apt-get install git -y 106 - name: Switch to temporal branch so we re-attach head 107 run: | 108 git switch -c temporal-pr-branch 109 git status 110 - name: Fetch complete history for blame information 111 run: | 112 git fetch --prune --no-tags --depth=1 origin +refs/heads/*:refs/remotes/origin/* 113 - name: Add ~/go/bin to PATH 114 run: | 115 echo "/home/runner/go/bin" >> $GITHUB_PATH 116 - name: Add /usr/local/bin to PATH 117 run: | 118 echo "/usr/local/bin" >> $GITHUB_PATH 119 - name: Restore go build cache 120 uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2 121 with: 122 path: ~/.cache/go-build 123 key: ${{ runner.os }}-go-build-v1-${{ github.run_id }} 124 - name: Install all tools required for building & testing 125 run: | 126 make install-test-tools-local 127 # We install kustomize in the dist directory 128 - name: Add dist to PATH 129 run: | 130 echo "/home/runner/work/argo-cd/argo-cd/dist" >> $GITHUB_PATH 131 - name: Setup git username and email 132 run: | 133 git config --global user.name "John Doe" 134 git config --global user.email "john.doe@example.com" 135 - name: Download and vendor all required packages 136 run: | 137 go mod download 138 - name: Run all unit tests 139 run: make test-local 140 - name: Generate code coverage artifacts 141 uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3 142 with: 143 name: code-coverage 144 path: coverage.out 145 - name: Generate test results artifacts 146 uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3 147 with: 148 name: test-results 149 path: test-results/ 150 151 test-go-race: 152 name: Run unit tests with -race for Go packages 153 runs-on: ubuntu-22.04 154 needs: 155 - build-go 156 env: 157 GITHUB_TOKEN: ${{ secrets.E2E_TEST_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} 158 GITLAB_TOKEN: ${{ secrets.E2E_TEST_GITLAB_TOKEN }} 159 steps: 160 - name: Create checkout directory 161 run: mkdir -p ~/go/src/github.com/argoproj 162 - name: Checkout code 163 uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 164 - name: Create symlink in GOPATH 165 run: ln -s $(pwd) ~/go/src/github.com/argoproj/argo-cd 166 - name: Setup Golang 167 uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.0.0 168 with: 169 go-version: ${{ env.GOLANG_VERSION }} 170 - name: Install required packages 171 run: | 172 sudo apt-get install git -y 173 - name: Switch to temporal branch so we re-attach head 174 run: | 175 git switch -c temporal-pr-branch 176 git status 177 - name: Fetch complete history for blame information 178 run: | 179 git fetch --prune --no-tags --depth=1 origin +refs/heads/*:refs/remotes/origin/* 180 - name: Add ~/go/bin to PATH 181 run: | 182 echo "/home/runner/go/bin" >> $GITHUB_PATH 183 - name: Add /usr/local/bin to PATH 184 run: | 185 echo "/usr/local/bin" >> $GITHUB_PATH 186 - name: Restore go build cache 187 uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2 188 with: 189 path: ~/.cache/go-build 190 key: ${{ runner.os }}-go-build-v1-${{ github.run_id }} 191 - name: Install all tools required for building & testing 192 run: | 193 make install-test-tools-local 194 # We install kustomize in the dist directory 195 - name: Add dist to PATH 196 run: | 197 echo "/home/runner/work/argo-cd/argo-cd/dist" >> $GITHUB_PATH 198 - name: Setup git username and email 199 run: | 200 git config --global user.name "John Doe" 201 git config --global user.email "john.doe@example.com" 202 - name: Download and vendor all required packages 203 run: | 204 go mod download 205 - name: Run all unit tests 206 run: make test-race-local 207 - name: Generate test results artifacts 208 uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3 209 with: 210 name: race-results 211 path: test-results/ 212 213 codegen: 214 name: Check changes to generated code 215 runs-on: ubuntu-22.04 216 steps: 217 - name: Checkout code 218 uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 219 - name: Setup Golang 220 uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.0.0 221 with: 222 go-version: ${{ env.GOLANG_VERSION }} 223 - name: Create symlink in GOPATH 224 run: | 225 mkdir -p ~/go/src/github.com/argoproj 226 cp -a ../argo-cd ~/go/src/github.com/argoproj 227 - name: Add ~/go/bin to PATH 228 run: | 229 echo "/home/runner/go/bin" >> $GITHUB_PATH 230 - name: Add /usr/local/bin to PATH 231 run: | 232 echo "/usr/local/bin" >> $GITHUB_PATH 233 - name: Download & vendor dependencies 234 run: | 235 # We need to vendor go modules for codegen yet 236 go mod download 237 go mod vendor -v 238 working-directory: /home/runner/go/src/github.com/argoproj/argo-cd 239 - name: Install toolchain for codegen 240 run: | 241 make install-codegen-tools-local 242 make install-go-tools-local 243 working-directory: /home/runner/go/src/github.com/argoproj/argo-cd 244 # We install kustomize in the dist directory 245 - name: Add dist to PATH 246 run: | 247 echo "/home/runner/work/argo-cd/argo-cd/dist" >> $GITHUB_PATH 248 - name: Run codegen 249 run: | 250 set -x 251 export GOPATH=$(go env GOPATH) 252 git checkout -- go.mod go.sum 253 make codegen-local 254 working-directory: /home/runner/go/src/github.com/argoproj/argo-cd 255 - name: Check nothing has changed 256 run: | 257 set -xo pipefail 258 git diff --exit-code -- . ':!go.sum' ':!go.mod' ':!assets/swagger.json' | tee codegen.patch 259 working-directory: /home/runner/go/src/github.com/argoproj/argo-cd 260 261 build-ui: 262 name: Build, test & lint UI code 263 runs-on: ubuntu-22.04 264 steps: 265 - name: Checkout code 266 uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 267 - name: Setup NodeJS 268 uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1 269 with: 270 node-version: '20.7.0' 271 - name: Restore node dependency cache 272 id: cache-dependencies 273 uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2 274 with: 275 path: ui/node_modules 276 key: ${{ runner.os }}-node-dep-v2-${{ hashFiles('**/yarn.lock') }} 277 - name: Install node dependencies 278 run: | 279 cd ui && yarn install --frozen-lockfile --ignore-optional --non-interactive 280 - name: Build UI code 281 run: | 282 yarn test 283 yarn build 284 env: 285 NODE_ENV: production 286 NODE_ONLINE_ENV: online 287 HOST_ARCH: amd64 288 working-directory: ui/ 289 - name: Run ESLint 290 run: yarn lint 291 working-directory: ui/ 292 293 analyze: 294 name: Process & analyze test artifacts 295 runs-on: ubuntu-22.04 296 needs: 297 - test-go 298 - build-ui 299 env: 300 sonar_secret: ${{ secrets.SONAR_TOKEN }} 301 steps: 302 - name: Checkout code 303 uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 304 with: 305 fetch-depth: 0 306 - name: Restore node dependency cache 307 id: cache-dependencies 308 uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2 309 with: 310 path: ui/node_modules 311 key: ${{ runner.os }}-node-dep-v2-${{ hashFiles('**/yarn.lock') }} 312 - name: Remove other node_modules directory 313 run: | 314 rm -rf ui/node_modules/argo-ui/node_modules 315 - name: Create test-results directory 316 run: | 317 mkdir -p test-results 318 - name: Get code coverage artifiact 319 uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2 320 with: 321 name: code-coverage 322 - name: Get test result artifact 323 uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2 324 with: 325 name: test-results 326 path: test-results 327 - name: Upload code coverage information to codecov.io 328 uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4 329 with: 330 file: coverage.out 331 - name: Perform static code analysis using SonarCloud 332 env: 333 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 334 SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} 335 SCANNER_VERSION: 4.2.0.1873 336 SCANNER_PATH: /tmp/cache/scanner 337 OS: linux 338 run: | 339 # We do not use the provided action, because it does contain an old 340 # version of the scanner, and also takes time to build. 341 set -e 342 mkdir -p ${SCANNER_PATH} 343 export SONAR_USER_HOME=${SCANNER_PATH}/.sonar 344 if [[ ! -x "${SCANNER_PATH}/sonar-scanner-${SCANNER_VERSION}-${OS}/bin/sonar-scanner" ]]; then 345 curl -Ol https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${SCANNER_VERSION}-${OS}.zip 346 unzip -qq -o sonar-scanner-cli-${SCANNER_VERSION}-${OS}.zip -d ${SCANNER_PATH} 347 fi 348 349 chmod +x ${SCANNER_PATH}/sonar-scanner-${SCANNER_VERSION}-${OS}/bin/sonar-scanner 350 chmod +x ${SCANNER_PATH}/sonar-scanner-${SCANNER_VERSION}-${OS}/jre/bin/java 351 352 # Explicitly set NODE_MODULES 353 export NODE_MODULES=${PWD}/ui/node_modules 354 export NODE_PATH=${PWD}/ui/node_modules 355 356 ${SCANNER_PATH}/sonar-scanner-${SCANNER_VERSION}-${OS}/bin/sonar-scanner 357 if: env.sonar_secret != '' 358 359 test-e2e: 360 name: Run end-to-end tests 361 runs-on: ubuntu-22.04 362 strategy: 363 fail-fast: false 364 matrix: 365 k3s-version: [v1.28.2, v1.27.6, v1.26.9, v1.25.14] 366 needs: 367 - build-go 368 env: 369 GOPATH: /home/runner/go 370 ARGOCD_FAKE_IN_CLUSTER: "true" 371 ARGOCD_SSH_DATA_PATH: "/tmp/argo-e2e/app/config/ssh" 372 ARGOCD_TLS_DATA_PATH: "/tmp/argo-e2e/app/config/tls" 373 ARGOCD_E2E_SSH_KNOWN_HOSTS: "../fixture/certs/ssh_known_hosts" 374 ARGOCD_E2E_K3S: "true" 375 ARGOCD_IN_CI: "true" 376 ARGOCD_E2E_APISERVER_PORT: "8088" 377 ARGOCD_APPLICATION_NAMESPACES: "argocd-e2e-external,argocd-e2e-external-2" 378 ARGOCD_SERVER: "127.0.0.1:8088" 379 GITHUB_TOKEN: ${{ secrets.E2E_TEST_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} 380 GITLAB_TOKEN: ${{ secrets.E2E_TEST_GITLAB_TOKEN }} 381 steps: 382 - name: Checkout code 383 uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 384 - name: Setup Golang 385 uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.0.0 386 with: 387 go-version: ${{ env.GOLANG_VERSION }} 388 - name: GH actions workaround - Kill XSP4 process 389 run: | 390 sudo pkill mono || true 391 - name: Install K3S 392 env: 393 INSTALL_K3S_VERSION: ${{ matrix.k3s-version }}+k3s1 394 run: | 395 set -x 396 curl -sfL https://get.k3s.io | sh - 397 sudo chmod -R a+rw /etc/rancher/k3s 398 sudo mkdir -p $HOME/.kube && sudo chown -R runner $HOME/.kube 399 sudo k3s kubectl config view --raw > $HOME/.kube/config 400 sudo chown runner $HOME/.kube/config 401 sudo chmod go-r $HOME/.kube/config 402 kubectl version 403 - name: Restore go build cache 404 uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2 405 with: 406 path: ~/.cache/go-build 407 key: ${{ runner.os }}-go-build-v1-${{ github.run_id }} 408 - name: Add ~/go/bin to PATH 409 run: | 410 echo "/home/runner/go/bin" >> $GITHUB_PATH 411 - name: Add /usr/local/bin to PATH 412 run: | 413 echo "/usr/local/bin" >> $GITHUB_PATH 414 - name: Add ./dist to PATH 415 run: | 416 echo "$(pwd)/dist" >> $GITHUB_PATH 417 - name: Download Go dependencies 418 run: | 419 go mod download 420 go install github.com/mattn/goreman@latest 421 - name: Install all tools required for building & testing 422 run: | 423 make install-test-tools-local 424 - name: Setup git username and email 425 run: | 426 git config --global user.name "John Doe" 427 git config --global user.email "john.doe@example.com" 428 - name: Pull Docker image required for tests 429 run: | 430 docker pull ghcr.io/dexidp/dex:v2.37.0 431 docker pull argoproj/argo-cd-ci-builder:v1.0.0 432 docker pull redis:7.0.15-alpine 433 - name: Create target directory for binaries in the build-process 434 run: | 435 mkdir -p dist 436 chown runner dist 437 - name: Run E2E server and wait for it being available 438 timeout-minutes: 30 439 run: | 440 set -x 441 # Something is weird in GH runners -- there's a phantom listener for 442 # port 8080 which is not visible in netstat -tulpen, but still there 443 # with a HTTP listener. We have API server listening on port 8088 444 # instead. 445 make start-e2e-local 2>&1 | sed -r "s/[[:cntrl:]]\[[0-9]{1,3}m//g" > /tmp/e2e-server.log & 446 count=1 447 until curl -f http://127.0.0.1:8088/healthz; do 448 sleep 10; 449 if test $count -ge 180; then 450 echo "Timeout" 451 exit 1 452 fi 453 count=$((count+1)) 454 done 455 - name: Run E2E testsuite 456 run: | 457 set -x 458 make test-e2e-local 459 - name: Upload e2e-server logs 460 uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3 461 with: 462 name: e2e-server-k8s${{ matrix.k3s-version }}.log 463 path: /tmp/e2e-server.log 464 if: ${{ failure() }}