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