github.com/argoproj-labs/argocd-operator@v0.10.0/.github/workflows/ci-build.yaml (about)

     1  name: Build and test the operator
     2  on:
     3    push:
     4      branches:
     5        - 'master'
     6        - 'release-*'
     7        - 'rhos-*'
     8    pull_request:
     9      branches:
    10        - 'master'
    11        - 'release-*'
    12        - 'rhos-*'
    13  
    14  jobs:
    15  
    16    build-operator:
    17      runs-on: ubuntu-latest
    18  
    19      steps:
    20  
    21        - name: Create checkout directory
    22          run: mkdir -p ~/go/src/github.com/argoproj-labs
    23  
    24        - name: Checkout code
    25          uses: actions/checkout@v2
    26  
    27        - name: Create symlink in GOPATH
    28          run: ln -s $(pwd) ~/go/src/github.com/argoproj-labs
    29  
    30        - name: Set up Go
    31          uses: actions/setup-go@v2
    32          with:
    33            go-version: '1.21'
    34  
    35        - name: Restore go build cache
    36          uses: actions/cache@v1
    37          with:
    38            path: ~/.cache/go-build
    39            key: ${{ runner.os }}-go-build-v1-${{ github.run_id }}
    40  
    41        - name: Build operator container image
    42          run: make docker-build IMG=quay.io/argoprojlabs/argocd-operator:latest
    43  
    44    test-e2e:
    45      name: Run end-to-end tests
    46      runs-on: ubuntu-latest
    47      strategy:
    48        matrix:
    49          k3s-version: [ v1.27.1 ]
    50          # k3s-version: [v1.20.2, v1.19.2, v1.18.9, v1.17.11, v1.16.15]
    51      steps:
    52        - name: Download kuttl plugin
    53          env:
    54            KUTTL_VERSION: '0.10.0'
    55            KUTTL_PLUGIN_SUM: 'ad21c0d2be495a8f6cfc0821e592ae61afd191ebd453156d9b204e2524fceaf2'
    56            KUTTL_PLUGIN_FILENAME: 'kubectl-kuttl_0.10.0_linux_x86_64'
    57          run: |
    58            set -x
    59            echo ${KUTTL_PLUGIN_FILENAME}
    60            curl -OL https://github.com/kudobuilder/kuttl/releases/download/v${KUTTL_VERSION}/${KUTTL_PLUGIN_FILENAME}
    61            echo "${KUTTL_PLUGIN_SUM}  ${KUTTL_PLUGIN_FILENAME}" | sha256sum -c -
    62            sudo mv ${KUTTL_PLUGIN_FILENAME} /usr/local/bin/kubectl-kuttl
    63            sudo chmod +x /usr/local/bin/kubectl-kuttl
    64            kubectl-kuttl version
    65        - name: Install K3D
    66          run: |
    67            set -x
    68            curl -s https://raw.githubusercontent.com/rancher/k3d/main/install.sh | bash
    69            sudo mkdir -p $HOME/.kube && sudo chown -R runner $HOME/.kube
    70            k3d cluster create --servers 3 --image rancher/k3s:${{ matrix.k3s-version }}-k3s1
    71            kubectl version
    72            k3d version
    73        - name: Checkout code
    74          uses: actions/checkout@v2
    75        - name: Setup Golang
    76          uses: actions/setup-go@v1
    77          with:
    78            go-version: '1.21'
    79        - name: GH actions workaround - Kill XSP4 process
    80          run: |
    81            sudo pkill mono || true
    82        - name: Restore go build cache
    83          uses: actions/cache@v1
    84          with:
    85            path: ~/.cache/go-build
    86            key: ${{ runner.os }}-go-build-v1-${{ github.run_id }}
    87        - name: Add /usr/local/bin to PATH
    88          run: |
    89            echo "/usr/local/bin" >> $GITHUB_PATH
    90        - name: Download Go dependencies
    91          run: |
    92            go mod download
    93        - name: Run the operator locally
    94          env:
    95            ARGOCD_CLUSTER_CONFIG_NAMESPACES: argocd-e2e-cluster-config
    96          run: |
    97            set -o pipefail
    98            make install generate fmt vet
    99            # Use tee to flush output to the log.  Other solutions like stdbuf don't work, not sure why.
   100            REDIS_CONFIG_PATH="build/redis" go run ./main.go 2>&1 | tee /tmp/e2e-operator-run.log &
   101        - name: Run tests
   102          run: |
   103            set -o pipefail
   104            bash hack/test.sh 2>&1 | tee /tmp/e2e-test.log
   105        - name: Upload operator logs
   106          uses: actions/upload-artifact@v2
   107          with:
   108            name: e2e-operator-run-${{ matrix.k3s-version }}.log
   109            path: /tmp/e2e-operator-run.log
   110          if: ${{ failure() }}
   111        - name: Upload test logs
   112          uses: actions/upload-artifact@v2
   113          with:
   114            name: e2e-test-${{ matrix.k3s-version }}.log
   115            path: /tmp/e2e-test.log
   116          if: ${{ failure() }}
   117        - name: Save application controller and server logs
   118          if: ${{ failure() }}
   119          run: |
   120            # Since the tests stop on the first failure, only one of the namespaces will exist
   121            set -x
   122            if [ $(kubectl get namespaces -o=name | grep '^namespace/argocd-e2e$') ]; then
   123              hack/pods.sh argocd-e2e > /tmp/pods.log
   124              kubectl logs -n argocd-e2e $(kubectl get po -n argocd-e2e -o=name | grep example-argocd-application-controller) > /tmp/e2e-application-controller.log
   125              kubectl logs -n argocd-e2e $(kubectl get po -n argocd-e2e -o=name | grep example-argocd-server) > /tmp/e2e-server.log
   126              kubectl describe -n argocd-e2e $(kubectl get po -n argocd-e2e -o=name | grep example-argocd-server) >> /tmp/e2e-server.log
   127            elif [ $(kubectl get namespaces -o=name | grep '^namespace/argocd-e2e-cluster-config$') ]; then
   128              hack/pods.sh argocd-e2e-cluster-config > /tmp/pods.log
   129              kubectl logs -n argocd-e2e-cluster-config $(kubectl get po -n argocd-e2e-cluster-config -o=name | grep example-argocd-application-controller) > /tmp/e2e-application-controller.log
   130              kubectl logs -n argocd-e2e-cluster-config $(kubectl get po -n argocd-e2e-cluster-config -o=name | grep example-argocd-server) > /tmp/e2e-server.log
   131              kubectl describe -n argocd-e2e-cluster-config $(kubectl get po -n argocd-e2e-cluster-config -o=name | grep example-argocd-server) >> /tmp/e2e-server.log
   132            fi
   133        - name: Upload application controller logs
   134          uses: actions/upload-artifact@v2
   135          with:
   136            name: e2e-application-controller-${{ matrix.k3s-version }}.log
   137            path: /tmp/e2e-application-controller.log
   138          if: ${{ failure() }}
   139        - name: Upload server logs
   140          uses: actions/upload-artifact@v2
   141          with:
   142            name: e2e-server-${{ matrix.k3s-version }}.log
   143            path: /tmp/e2e-server.log
   144          if: ${{ failure() }}
   145        - name: Upload pod descriptions
   146          uses: actions/upload-artifact@v2
   147          with:
   148            name: e2e-pods-${{ matrix.k3s-version }}.log
   149            path: /tmp/pods.log
   150          if: ${{ failure() }}