From f1390fecab4caaf83154f41a78887c5e680d32c7 Mon Sep 17 00:00:00 2001 From: Adam Boutcher Date: Fri, 13 Aug 2021 17:49:28 +0100 Subject: [PATCH] Faster workflow for testing --- .github/workflows/quick-dev.yml | 149 ++++++++++++++++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 .github/workflows/quick-dev.yml diff --git a/.github/workflows/quick-dev.yml b/.github/workflows/quick-dev.yml new file mode 100644 index 00000000..1a42f959 --- /dev/null +++ b/.github/workflows/quick-dev.yml @@ -0,0 +1,149 @@ +name: Development Build +on: + push: + branches: + - dev + paths-ignore: + - '**.md' + +jobs: + + frontend: + runs-on: [self-hosted, linux, aboutcher-hosted] + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-go@v2 + with: + go-version: 1.15.x + - uses: actions/setup-node@v1 + with: + node-version: 12.18.2 + + - name: Set Version + run: | + echo "$(go env GOPATH)/bin" >> $GITHUB_PATH + echo "VERSION=$(cat version.txt)" >> $GITHUB_ENV + shell: bash + + - name: Install Global Dependencies + run: npm install -g yarn sass cross-env mjml + + - name: Download Frontend Dependencies + working-directory: ./frontend + run: yarn + + - name: Download Go mods + run: | + go mod download + go mod verify + make test-deps + + - name: Build Frontend Statping + env: + VERSION: ${{ env.VERSION }} + COMMIT: ${{ github.sha }} + MJML_APP: ${{ secrets.MJML_APP }} + MJML_PRIVATE: ${{ secrets.MJML_PRIVATE }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + run: make clean generate compile + + - name: Upload Compiled Frontend (rice-box.go) + uses: actions/upload-artifact@v1 + with: + name: static-rice-box + path: ./source + + build: + needs: frontend + runs-on: [self-hosted, linux, aboutcher-hosted] + strategy: + matrix: + platform: [linux] + arch: [386, amd64, arm-7, arm-6, arm64] + include: + - platform: darwin + arch: amd64 + - platform: windows + arch: amd64 + + steps: + - uses: actions/checkout@v2 + + - name: Download Compiled Frontend (rice-box.go) + uses: actions/download-artifact@v1 + with: + name: static-rice-box + path: ./source + + - name: Add GOBIN to PATH + run: | + echo "VERSION=$(cat version.txt)" >> $GITHUB_ENV + shell: bash + + - name: Set Linux Build Flags + if: matrix.platform == 'linux' + run: | + echo "BUILD_FLAGS=-extldflags -static" >> $GITHUB_ENV + echo "XGO_TAGS=netgo osusergo linux sqlite_omit_load_extension" >> $GITHUB_ENV + shell: bash + + - name: Set Darwin Build Flags + if: matrix.platform == 'darwin' + run: echo "XGO_TAGS=netgo osusergo darwin sqlite_omit_load_extension" >> $GITHUB_ENV + shell: bash + + - name: Set Windows Build Flags + if: matrix.platform == 'windows' + run: | + echo "BUILD_FLAGS=-extldflags -static" >> $GITHUB_ENV + echo "XGO_TAGS=netgo osusergo sqlite_omit_load_extension" >> $GITHUB_ENV + shell: bash + + - name: Build ${{ matrix.platform }}/${{ matrix.arch }} + uses: crazy-max/ghaction-xgo@v1 + env: + VERSION: ${{ env.VERSION }} + COMMIT: ${{ github.sha }} + with: + xgo_version: latest + go_version: 1.15.x + dest: build + prefix: statping + targets: ${{ matrix.platform }}/${{ matrix.arch }} + v: false + x: false + pkg: cmd + buildmode: pie + tags: ${{ env.XGO_TAGS }} + ldflags: -s -w -X main.VERSION=${{ env.VERSION }} -X main.COMMIT=${{ env.COMMIT }} ${{ env.BUILD_FLAGS }} + + - name: Compress Linux Builds + if: matrix.platform == 'linux' + run: | + cd build + mv statping-linux-${{ matrix.arch }} statping + chmod +x statping + tar -czvf statping-linux-${{ matrix.arch }}.tar.gz statping + rm -rf statping + echo "compressed=statping-linux-${{ matrix.arch }}.tar.gz" >> $GITHUB_ENV + + - name: Compress Windows Builds + if: matrix.platform == 'windows' + run: | + cd build + mv statping-windows-4.0-${{ matrix.arch }}.exe statping.exe + chmod +x statping.exe + zip statping-windows-${{ matrix.arch }}.zip statping.exe + rm -rf statping.exe + echo "compressed=statping-windows-${{ matrix.arch }}.zip" >> $GITHUB_ENV + + - name: Compress Darwin Builds + if: matrix.platform == 'darwin' + run: | + cd build + mv statping-darwin-10.6-${{ matrix.arch }} statping + chmod +x statping + tar -czvf statping-darwin-${{ matrix.arch }}.tar.gz statping + rm -rf statping + echo "compressed=statping-darwin-${{ matrix.arch }}.tar.gz" >> $GITHUB_ENV