github.com/argoproj/argo-cd/v3@v3.2.1/.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 # renovate: datasource=golang-version packageName=golang 17 GOLANG_VERSION: '1.25.0' 18 19 concurrency: 20 group: ${{ github.workflow }}-${{ github.ref }} 21 cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} 22 23 permissions: 24 contents: read 25 26 jobs: 27 changes: 28 runs-on: ubuntu-latest 29 outputs: 30 backend: ${{ steps.filter.outputs.backend_any_changed }} 31 frontend: ${{ steps.filter.outputs.frontend_any_changed }} 32 docs: ${{ steps.filter.outputs.docs_any_changed }} 33 steps: 34 - uses: actions/checkout@8410ad0602e1e429cee44a835ae9f77f654a6694 # v4.0.0 35 - uses: tj-actions/changed-files@24d32ffd492484c1d75e0c0b894501ddb9d30d62 # v47.0.0 36 id: filter 37 with: 38 # Any file which is not under docs/, ui/ or is not a markdown file is counted as a backend file 39 files_yaml: | 40 backend: 41 - '!ui/**' 42 - '!**.md' 43 - '!**/*.md' 44 - '!docs/**' 45 frontend: 46 - 'ui/**' 47 - Dockerfile 48 docs: 49 - 'docs/**' 50 check-go: 51 name: Ensure Go modules synchronicity 52 if: ${{ needs.changes.outputs.backend == 'true' }} 53 runs-on: ubuntu-22.04 54 needs: 55 - changes 56 steps: 57 - name: Checkout code 58 uses: actions/checkout@8410ad0602e1e429cee44a835ae9f77f654a6694 # v4.0.0 59 - name: Setup Golang 60 uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0 61 with: 62 go-version: ${{ env.GOLANG_VERSION }} 63 - name: Download all Go modules 64 run: | 65 go mod download 66 - name: Check for tidiness of go.mod and go.sum 67 run: | 68 go mod tidy 69 git diff --exit-code -- . 70 71 build-go: 72 name: Build & cache Go code 73 if: ${{ needs.changes.outputs.backend == 'true' }} 74 runs-on: ubuntu-22.04 75 needs: 76 - changes 77 steps: 78 - name: Checkout code 79 uses: actions/checkout@8410ad0602e1e429cee44a835ae9f77f654a6694 # v4.0.0 80 - name: Setup Golang 81 uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0 82 with: 83 go-version: ${{ env.GOLANG_VERSION }} 84 - name: Restore go build cache 85 uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4 86 with: 87 path: ~/.cache/go-build 88 key: ${{ runner.os }}-go-build-v1-${{ github.run_id }} 89 - name: Download all Go modules 90 run: | 91 go mod download 92 - name: Compile all packages 93 run: make build-local 94 95 lint-go: 96 permissions: 97 contents: read # for actions/checkout to fetch code 98 pull-requests: read # for golangci/golangci-lint-action to fetch pull requests 99 name: Lint Go code 100 if: ${{ needs.changes.outputs.backend == 'true' }} 101 runs-on: ubuntu-22.04 102 needs: 103 - changes 104 steps: 105 - name: Checkout code 106 uses: actions/checkout@8410ad0602e1e429cee44a835ae9f77f654a6694 # v4.0.0 107 - name: Setup Golang 108 uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0 109 with: 110 go-version: ${{ env.GOLANG_VERSION }} 111 - name: Run golangci-lint 112 uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0 113 with: 114 # renovate: datasource=go packageName=github.com/golangci/golangci-lint versioning=regex:^v(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)?$ 115 version: v2.4.0 116 args: --verbose 117 118 test-go: 119 name: Run unit tests for Go packages 120 if: ${{ needs.changes.outputs.backend == 'true' }} 121 runs-on: ubuntu-22.04 122 needs: 123 - build-go 124 - changes 125 env: 126 GITHUB_TOKEN: ${{ secrets.E2E_TEST_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} 127 GITLAB_TOKEN: ${{ secrets.E2E_TEST_GITLAB_TOKEN }} 128 steps: 129 - name: Create checkout directory 130 run: mkdir -p ~/go/src/github.com/argoproj 131 - name: Checkout code 132 uses: actions/checkout@8410ad0602e1e429cee44a835ae9f77f654a6694 # v4.0.0 133 - name: Create symlink in GOPATH 134 run: ln -s $(pwd) ~/go/src/github.com/argoproj/argo-cd 135 - name: Setup Golang 136 uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0 137 with: 138 go-version: ${{ env.GOLANG_VERSION }} 139 - name: Install required packages 140 run: | 141 sudo apt-get install git -y 142 - name: Switch to temporal branch so we re-attach head 143 run: | 144 git switch -c temporal-pr-branch 145 git status 146 - name: Fetch complete history for blame information 147 run: | 148 git fetch --prune --no-tags --depth=1 origin +refs/heads/*:refs/remotes/origin/* 149 - name: Add ~/go/bin to PATH 150 run: | 151 echo "/home/runner/go/bin" >> $GITHUB_PATH 152 - name: Add /usr/local/bin to PATH 153 run: | 154 echo "/usr/local/bin" >> $GITHUB_PATH 155 - name: Restore go build cache 156 uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4 157 with: 158 path: ~/.cache/go-build 159 key: ${{ runner.os }}-go-build-v1-${{ github.run_id }} 160 - name: Install all tools required for building & testing 161 run: | 162 make install-test-tools-local 163 # We install kustomize in the dist directory 164 - name: Add dist to PATH 165 run: | 166 echo "/home/runner/work/argo-cd/argo-cd/dist" >> $GITHUB_PATH 167 - name: Setup git username and email 168 run: | 169 git config --global user.name "John Doe" 170 git config --global user.email "john.doe@example.com" 171 - name: Download and vendor all required packages 172 run: | 173 go mod download 174 - name: Run all unit tests 175 run: make test-local 176 - name: Generate test results artifacts 177 uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 178 with: 179 name: test-results 180 path: test-results 181 182 test-go-race: 183 name: Run unit tests with -race for Go packages 184 if: ${{ needs.changes.outputs.backend == 'true' }} 185 runs-on: ubuntu-22.04 186 needs: 187 - build-go 188 - changes 189 env: 190 GITHUB_TOKEN: ${{ secrets.E2E_TEST_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} 191 GITLAB_TOKEN: ${{ secrets.E2E_TEST_GITLAB_TOKEN }} 192 steps: 193 - name: Create checkout directory 194 run: mkdir -p ~/go/src/github.com/argoproj 195 - name: Checkout code 196 uses: actions/checkout@8410ad0602e1e429cee44a835ae9f77f654a6694 # v4.0.0 197 - name: Create symlink in GOPATH 198 run: ln -s $(pwd) ~/go/src/github.com/argoproj/argo-cd 199 - name: Setup Golang 200 uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0 201 with: 202 go-version: ${{ env.GOLANG_VERSION }} 203 - name: Install required packages 204 run: | 205 sudo apt-get install git -y 206 - name: Switch to temporal branch so we re-attach head 207 run: | 208 git switch -c temporal-pr-branch 209 git status 210 - name: Fetch complete history for blame information 211 run: | 212 git fetch --prune --no-tags --depth=1 origin +refs/heads/*:refs/remotes/origin/* 213 - name: Add ~/go/bin to PATH 214 run: | 215 echo "/home/runner/go/bin" >> $GITHUB_PATH 216 - name: Add /usr/local/bin to PATH 217 run: | 218 echo "/usr/local/bin" >> $GITHUB_PATH 219 - name: Restore go build cache 220 uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4 221 with: 222 path: ~/.cache/go-build 223 key: ${{ runner.os }}-go-build-v1-${{ github.run_id }} 224 - name: Install all tools required for building & testing 225 run: | 226 make install-test-tools-local 227 # We install kustomize in the dist directory 228 - name: Add dist to PATH 229 run: | 230 echo "/home/runner/work/argo-cd/argo-cd/dist" >> $GITHUB_PATH 231 - name: Setup git username and email 232 run: | 233 git config --global user.name "John Doe" 234 git config --global user.email "john.doe@example.com" 235 - name: Download and vendor all required packages 236 run: | 237 go mod download 238 - name: Run all unit tests 239 run: make test-race-local 240 - name: Generate test results artifacts 241 uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 242 with: 243 name: race-results 244 path: test-results/ 245 246 codegen: 247 name: Check changes to generated code 248 if: ${{ needs.changes.outputs.backend == 'true' || needs.changes.outputs.docs == 'true'}} 249 runs-on: ubuntu-22.04 250 needs: 251 - changes 252 steps: 253 - name: Checkout code 254 uses: actions/checkout@8410ad0602e1e429cee44a835ae9f77f654a6694 # v4.0.0 255 - name: Setup Golang 256 uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0 257 with: 258 go-version: ${{ env.GOLANG_VERSION }} 259 - name: Create symlink in GOPATH 260 run: | 261 mkdir -p ~/go/src/github.com/argoproj 262 cp -a ../argo-cd ~/go/src/github.com/argoproj 263 - name: Add ~/go/bin to PATH 264 run: | 265 echo "/home/runner/go/bin" >> $GITHUB_PATH 266 - name: Add /usr/local/bin to PATH 267 run: | 268 echo "/usr/local/bin" >> $GITHUB_PATH 269 - name: Download & vendor dependencies 270 run: | 271 # We need to vendor go modules for codegen yet 272 go mod download 273 go mod vendor -v 274 working-directory: /home/runner/go/src/github.com/argoproj/argo-cd 275 - name: Install toolchain for codegen 276 run: | 277 make install-codegen-tools-local 278 make install-go-tools-local 279 working-directory: /home/runner/go/src/github.com/argoproj/argo-cd 280 # We install kustomize in the dist directory 281 - name: Add dist to PATH 282 run: | 283 echo "/home/runner/work/argo-cd/argo-cd/dist" >> $GITHUB_PATH 284 - name: Run codegen 285 run: | 286 set -x 287 export GOPATH=$(go env GOPATH) 288 git checkout -- go.mod go.sum 289 make codegen-local 290 working-directory: /home/runner/go/src/github.com/argoproj/argo-cd 291 - name: Check nothing has changed 292 run: | 293 set -xo pipefail 294 git diff --exit-code -- . ':!go.sum' ':!go.mod' ':!assets/swagger.json' | tee codegen.patch 295 working-directory: /home/runner/go/src/github.com/argoproj/argo-cd 296 297 build-ui: 298 name: Build, test & lint UI code 299 # We run UI logic for backend changes so that we have a complete set of coverage documents to send to codecov. 300 if: ${{ needs.changes.outputs.backend == 'true' || needs.changes.outputs.frontend == 'true' }} 301 runs-on: ubuntu-22.04 302 needs: 303 - changes 304 steps: 305 - name: Checkout code 306 uses: actions/checkout@8410ad0602e1e429cee44a835ae9f77f654a6694 # v4.0.0 307 - name: Setup NodeJS 308 uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 309 with: 310 # renovate: datasource=node-version packageName=node versioning=node 311 node-version: '22.9.0' 312 - name: Restore node dependency cache 313 id: cache-dependencies 314 uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4 315 with: 316 path: ui/node_modules 317 key: ${{ runner.os }}-node-dep-v2-${{ hashFiles('**/yarn.lock') }} 318 - name: Install node dependencies 319 run: | 320 cd ui && yarn install --frozen-lockfile --ignore-optional --non-interactive 321 - name: Build UI code 322 run: | 323 yarn test 324 yarn build 325 env: 326 NODE_ENV: production 327 NODE_ONLINE_ENV: online 328 HOST_ARCH: amd64 329 # If we're on the master branch, set the codecov token so that we upload bundle analysis 330 CODECOV_TOKEN: ${{ github.ref == 'refs/heads/master' && secrets.CODECOV_TOKEN || '' }} 331 working-directory: ui/ 332 - name: Run ESLint 333 run: yarn lint 334 working-directory: ui/ 335 336 shellcheck: 337 runs-on: ubuntu-latest 338 steps: 339 - uses: actions/checkout@8410ad0602e1e429cee44a835ae9f77f654a6694 # v4.0.0 340 - run: | 341 sudo apt-get install shellcheck 342 shellcheck -e SC2059 -e SC2154 -e SC2034 -e SC2016 -e SC1091 $(find . -type f -name '*.sh' | grep -v './ui/node_modules') | tee sc.log 343 test ! -s sc.log 344 345 analyze: 346 name: Process & analyze test artifacts 347 if: ${{ needs.changes.outputs.backend == 'true' || needs.changes.outputs.frontend == 'true' }} 348 runs-on: ubuntu-22.04 349 needs: 350 - test-go 351 - build-ui 352 - changes 353 - test-e2e 354 env: 355 sonar_secret: ${{ secrets.SONAR_TOKEN }} 356 steps: 357 - name: Checkout code 358 uses: actions/checkout@8410ad0602e1e429cee44a835ae9f77f654a6694 # v4.0.0 359 with: 360 fetch-depth: 0 361 - name: Restore node dependency cache 362 id: cache-dependencies 363 uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4 364 with: 365 path: ui/node_modules 366 key: ${{ runner.os }}-node-dep-v2-${{ hashFiles('**/yarn.lock') }} 367 - name: Remove other node_modules directory 368 run: | 369 rm -rf ui/node_modules/argo-ui/node_modules 370 - name: Get e2e code coverage 371 uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0 372 with: 373 name: e2e-code-coverage 374 path: e2e-code-coverage 375 - name: Get unit test code coverage 376 uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0 377 with: 378 name: test-results 379 path: test-results 380 - name: combine-go-coverage 381 # We generate coverage reports for all Argo CD components, but only the applicationset-controller, 382 # app-controller, repo-server, and commit-server report contain coverage data. The other components currently 383 # don't shut down gracefully, so no coverage data is produced. Once those components are fixed, we can add 384 # references to their coverage output directories. 385 run: | 386 go tool covdata percent -i=test-results,e2e-code-coverage/applicationset-controller,e2e-code-coverage/repo-server,e2e-code-coverage/app-controller,e2e-code-coverage/commit-server -o test-results/full-coverage.out 387 - name: Upload code coverage information to codecov.io 388 uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1 389 with: 390 files: test-results/full-coverage.out 391 fail_ci_if_error: true 392 env: 393 CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} 394 - name: Upload test results to Codecov 395 if: github.ref == 'refs/heads/master' && github.event_name == 'push' && github.repository == 'argoproj/argo-cd' 396 uses: codecov/test-results-action@47f89e9acb64b76debcd5ea40642d25a4adced9f # v1.1.1 397 with: 398 file: test-results/junit.xml 399 fail_ci_if_error: true 400 token: ${{ secrets.CODECOV_TOKEN }} 401 - name: Perform static code analysis using SonarCloud 402 env: 403 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 404 SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} 405 uses: SonarSource/sonarqube-scan-action@1a6d90ebcb0e6a6b1d87e37ba693fe453195ae25 # v5.3.1 406 if: env.sonar_secret != '' 407 test-e2e: 408 name: Run end-to-end tests 409 if: ${{ needs.changes.outputs.backend == 'true' }} 410 runs-on: oracle-vm-16cpu-64gb-x86-64 411 strategy: 412 fail-fast: false 413 matrix: 414 # latest: true means that this version mush upload the coverage report to codecov.io 415 # We designate the latest version because we only collect code coverage for that version. 416 k3s: 417 - version: v1.33.1 418 latest: true 419 - version: v1.32.1 420 latest: false 421 - version: v1.31.0 422 latest: false 423 - version: v1.30.4 424 latest: false 425 needs: 426 - build-go 427 - changes 428 env: 429 GOPATH: /home/ubuntu/go 430 ARGOCD_FAKE_IN_CLUSTER: 'true' 431 ARGOCD_SSH_DATA_PATH: '/tmp/argo-e2e/app/config/ssh' 432 ARGOCD_TLS_DATA_PATH: '/tmp/argo-e2e/app/config/tls' 433 ARGOCD_E2E_SSH_KNOWN_HOSTS: '../fixture/certs/ssh_known_hosts' 434 ARGOCD_E2E_K3S: 'true' 435 ARGOCD_IN_CI: 'true' 436 ARGOCD_E2E_APISERVER_PORT: '8088' 437 ARGOCD_APPLICATION_NAMESPACES: 'argocd-e2e-external,argocd-e2e-external-2' 438 ARGOCD_SERVER: '127.0.0.1:8088' 439 GITHUB_TOKEN: ${{ secrets.E2E_TEST_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} 440 GITLAB_TOKEN: ${{ secrets.E2E_TEST_GITLAB_TOKEN }} 441 steps: 442 - name: Free Disk Space (Ubuntu) 443 uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be 444 with: 445 large-packages: false 446 docker-images: false 447 swap-storage: false 448 tool-cache: false 449 - name: Checkout code 450 uses: actions/checkout@8410ad0602e1e429cee44a835ae9f77f654a6694 # v4.0.0 451 - name: Setup Golang 452 uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0 453 with: 454 go-version: ${{ env.GOLANG_VERSION }} 455 - name: GH actions workaround - Kill XSP4 process 456 run: | 457 sudo pkill mono || true 458 - name: Install K3S 459 env: 460 INSTALL_K3S_VERSION: ${{ matrix.k3s.version }}+k3s1 461 run: | 462 set -x 463 curl -sfL https://get.k3s.io | sh - 464 sudo chmod -R a+rw /etc/rancher/k3s 465 sudo mkdir -p $HOME/.kube && sudo chown -R ubuntu $HOME/.kube 466 sudo k3s kubectl config view --raw > $HOME/.kube/config 467 sudo chown ubuntu $HOME/.kube/config 468 sudo chmod go-r $HOME/.kube/config 469 kubectl version 470 - name: Restore go build cache 471 uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4 472 with: 473 path: ~/.cache/go-build 474 key: ${{ runner.os }}-go-build-v1-${{ github.run_id }} 475 - name: Add ~/go/bin to PATH 476 run: | 477 echo "/home/ubuntu/go/bin" >> $GITHUB_PATH 478 - name: Add /usr/local/bin to PATH 479 run: | 480 echo "/usr/local/bin" >> $GITHUB_PATH 481 - name: Add ./dist to PATH 482 run: | 483 echo "$(pwd)/dist" >> $GITHUB_PATH 484 - name: Download Go dependencies 485 run: | 486 go mod download 487 go install github.com/mattn/goreman@latest 488 - name: Install all tools required for building & testing 489 run: | 490 make install-test-tools-local 491 - name: Setup git username and email 492 run: | 493 git config --global user.name "John Doe" 494 git config --global user.email "john.doe@example.com" 495 - name: Pull Docker image required for tests 496 run: | 497 docker pull ghcr.io/dexidp/dex:v2.43.0 498 docker pull argoproj/argo-cd-ci-builder:v1.0.0 499 docker pull redis:8.2.2-alpine 500 - name: Create target directory for binaries in the build-process 501 run: | 502 mkdir -p dist 503 chown ubuntu dist 504 - name: Run E2E server and wait for it being available 505 timeout-minutes: 30 506 run: | 507 set -x 508 # Something is weird in GH runners -- there's a phantom listener for 509 # port 8080 which is not visible in netstat -tulpen, but still there 510 # with a HTTP listener. We have API server listening on port 8088 511 # instead. 512 make start-e2e-local COVERAGE_ENABLED=true 2>&1 | sed -r "s/[[:cntrl:]]\[[0-9]{1,3}m//g" > /tmp/e2e-server.log & 513 count=1 514 until curl -f http://127.0.0.1:8088/healthz; do 515 sleep 10; 516 if test $count -ge 180; then 517 echo "Timeout" 518 exit 1 519 fi 520 count=$((count+1)) 521 done 522 - name: Run E2E testsuite 523 run: | 524 set -x 525 make test-e2e-local 526 goreman run stop-all || echo "goreman trouble" 527 sleep 30 528 - name: Upload e2e coverage report 529 uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 530 with: 531 name: e2e-code-coverage 532 path: /tmp/coverage 533 if: ${{ matrix.k3s.latest }} 534 - name: Upload e2e-server logs 535 uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 536 with: 537 name: e2e-server-k8s${{ matrix.k3s.version }}.log 538 path: /tmp/e2e-server.log 539 if: ${{ failure() }} 540 541 # workaround for status checks -- check this one job instead of each individual E2E job in the matrix 542 # this allows us to skip the entire matrix when it doesn't need to run while still having accurate status checks 543 # see: 544 # https://github.com/argoproj/argo-workflows/pull/12006 545 # https://github.com/orgs/community/discussions/9141#discussioncomment-2296809 546 # https://github.com/orgs/community/discussions/26822#discussioncomment-3305794 547 test-e2e-composite-result: 548 name: E2E Tests - Composite result 549 if: ${{ always() }} 550 needs: 551 - test-e2e 552 - changes 553 runs-on: ubuntu-22.04 554 steps: 555 - run: | 556 result="${{ needs.test-e2e.result }}" 557 # mark as successful even if skipped 558 if [[ $result == "success" || $result == "skipped" ]]; then 559 exit 0 560 else 561 exit 1 562 fi