name: Run Tests on: push: branches: - 'develop' pull_request: branches: - 'develop' jobs: build: strategy: # Default is true, cancels jobs for other platforms in the matrix if one fails fail-fast: false matrix: os: [ ubuntu-20.04 ] go: [ 1.15.6 ] goos: [ linux ] goarch: [ amd64, arm64 ] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v2 - uses: actions/setup-go@v2 with: go-version: ${{ matrix.go }} - name: Print Environment id: env run: | printf "Go Executable Path: $(which go)\n" printf "Go Version: $(go version)\n" printf "\n\nGo Environment:\n\n" go env printf "\n\nSystem Environment:\n\n" env echo "::set-output name=version_tag::${GITHUB_REF/refs\/tags\//}" echo "::set-output name=short_sha::$(git rev-parse --short HEAD)" echo "::set-output name=go_cache::$(go env GOCACHE)" - name: Build Cache uses: actions/cache@v2 with: path: ${{ steps.env.outputs.go_cache }} key: ${{ runner.os }}-${{ matrix.go }}-go-${{ hashFiles('**/go.sum') }} restore-keys: | ${{ runner.os }}-${{ matrix.go }}-go - name: Get Dependencies run: | go get -v -t -d ./... - name: Build env: GOOS: ${{ matrix.goos }} GOARCH: ${{ matrix.goarch }} CGO_ENABLED: 0 SRC_PATH: github.com/pterodactyl/wings run: | go build -v -trimpath -ldflags="-s -w -X ${SRC_PATH}/system.Version=dev-${GIT_COMMIT:0:7}" -o build/wings_${{ matrix.goos }}_${{ matrix.goarch }} wings.go - name: Test run: go test ./... - name: Compress binary and make it executable if: ${{ github.ref == 'refs/heads/develop' || github.event_name == 'pull_request' }} run: | upx build/wings_${{ matrix.goos }}_${{ matrix.goarch }} && chmod +x build/wings_${{ matrix.goos }}_${{ matrix.goarch }} - uses: actions/upload-artifact@v2 if: ${{ github.ref == 'refs/heads/develop' || github.event_name == 'pull_request' }} with: name: wings_${{ matrix.goos }}_${{ matrix.goarch }} path: build/wings_${{ matrix.goos }}_${{ matrix.goarch }} - uses: actions/upload-artifact@v2 if: ${{ github.ref == 'refs/heads/develop' || github.event_name == 'pull_request' }} with: name: wings_${{ matrix.goos }}_${{ matrix.goarch }} path: build/wings_${{ matrix.goos }}_${{ matrix.goarch }}