github.com/google/cloudprober@v0.11.3/.github/workflows/go.yml (about) 1 name: Go Build and Test 2 on: [push, pull_request] 3 jobs: 4 5 build: 6 name: Build and Test 7 env: 8 # UDP tests use this variable to disable IPv6. 9 TRAVIS: yes 10 runs-on: ${{ matrix.os }} 11 strategy: 12 matrix: 13 os: [ubuntu-latest, windows-latest, macos-latest] 14 steps: 15 - name: Set up Go 1.16 16 uses: actions/setup-go@v1 17 with: 18 go-version: 1.16 19 id: go 20 21 - name: Check out code into the Go module directory 22 uses: actions/checkout@v1 23 24 - name: Set BIN_DIR and ZIP env variable 25 run: | 26 echo "BIN_DIR=cloudprober-$(git describe --tags)-$(echo ${{ matrix.os }} | sed 's/-latest//')-$(uname -m)" >> $GITHUB_ENV 27 28 - name: Override BIN_DIR env variable on windows 29 if: ${{ matrix.os == 'windows-latest' }} 30 run: | 31 echo "BIN_DIR=cloudprober-$(git describe --tags)-windows-x86_64" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append 32 33 - name: Set environment varible to skip UDP test on MAC OS 34 if: ${{ matrix.os == 'macos-latest' }} 35 run: echo "EXTRA_TEST_FLAGS=-tags skip_udp_probe_test" >> $GITHUB_ENV 36 37 - name: Get dependencies 38 run: | 39 go get -v -t -d ./... 40 41 - name: Build 42 run: go build -v . 43 44 - name: Test 45 run: go test ${{ env.EXTRA_TEST_FLAGS }} -v -race -covermode=atomic ./... 46 47 - name: Build cloudprober Binary 48 run: make cloudprober 49 50 - run: | 51 mkdir -p ${{ env.BIN_DIR }} 52 chmod a+rx cloudprober 53 cp cloudprober ${{ env.BIN_DIR }}/ 54 55 - if: ${{ matrix.os != 'windows-latest' }} 56 run: zip -r ${{ env.ZIP_FLAG }} ${{ env.BIN_DIR }}.zip ${{ env.BIN_DIR }}/ 57 58 - if: ${{ matrix.os == 'windows-latest' }} 59 run: 7z a ${{ env.ZIP_FLAG }} ${{ env.BIN_DIR }}.zip ${{ env.BIN_DIR }}/ 60 61 - name: Upload cloudprober binary zip 62 uses: actions/upload-artifact@v2 63 with: 64 name: cloudprober-${{ matrix.os }}-zipped 65 path: ${{ env.BIN_DIR }}.zip 66 67 # This binary is used for docker images 68 - name: Upload cloudprober binary for docker image 69 if: ${{ matrix.os == 'ubuntu-latest' }} 70 uses: actions/upload-artifact@v2 71 with: 72 name: cloudprober-binary-${{ matrix.os }} 73 path: cloudprober 74 75 build_and_push_docker: 76 name: Build and push docker image 77 if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags') 78 needs: [build] 79 runs-on: ubuntu-latest 80 81 steps: 82 - name: Check out code into the Go module directory 83 uses: actions/checkout@v1 84 85 - name: Download cloudprober binary 86 uses: actions/download-artifact@v1 87 with: 88 name: cloudprober-binary-ubuntu-latest 89 key: cloudprober 90 91 - name: Build Docker Image 92 run: | 93 mv cloudprober-binary-ubuntu-latest/cloudprober cloudprober 94 chmod a+rx cloudprober 95 make docker_build 96 97 - name: Push Docker Image 98 env: 99 DOCKER_USER: ${{ secrets.docker_login }} 100 DOCKER_PASS: ${{ secrets.docker_pass }} 101 run: make docker_push DOCKER_VERSION=master 102 103 - name: Push Docker Image With Version 104 if: startsWith(github.ref, 'refs/tags') 105 env: 106 DOCKER_USER: ${{ secrets.docker_login }} 107 DOCKER_PASS: ${{ secrets.docker_pass }} 108 run: make docker_push_tagged 109 110 build_and_push_contrib_docker: 111 name: Build and push contrib docker image 112 if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags') 113 needs: [build] 114 runs-on: ubuntu-latest 115 116 steps: 117 - name: Check out code into the Go module directory 118 uses: actions/checkout@v1 119 120 - name: Download cloudprober binary 121 uses: actions/download-artifact@v1 122 with: 123 name: cloudprober-binary-ubuntu-latest 124 key: cloudprober 125 126 - name: Build Docker Image 127 run: | 128 mv cloudprober-binary-ubuntu-latest/cloudprober contrib/cloudprober 129 chmod a+rx contrib/cloudprober 130 make -C contrib docker_build 131 132 - name: Push Docker Image 133 env: 134 DOCKER_USER: ${{ secrets.docker_login }} 135 DOCKER_PASS: ${{ secrets.docker_pass }} 136 run: make -C contrib docker_push DOCKER_VERSION=master 137 138 - name: Push Docker Image With Version 139 if: startsWith(github.ref, 'refs/tags') 140 env: 141 DOCKER_USER: ${{ secrets.docker_login }} 142 DOCKER_PASS: ${{ secrets.docker_pass }} 143 run: make -C contrib docker_push_tagged