2020-11-15 04:42:12 +00:00
|
|
|
name: Run Tests
|
2020-07-04 21:29:03 +00:00
|
|
|
on:
|
|
|
|
push:
|
2020-12-08 16:11:15 +00:00
|
|
|
branches:
|
2021-07-12 17:06:22 +00:00
|
|
|
- develop
|
2020-07-04 21:29:03 +00:00
|
|
|
pull_request:
|
2020-12-08 16:11:15 +00:00
|
|
|
branches:
|
2021-07-12 17:06:22 +00:00
|
|
|
- develop
|
2020-07-04 21:29:03 +00:00
|
|
|
jobs:
|
|
|
|
build:
|
2020-10-17 21:13:06 +00:00
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
os: [ ubuntu-20.04 ]
|
2021-08-24 19:28:17 +00:00
|
|
|
go: [ '^1.17' ]
|
2020-10-17 21:13:06 +00:00
|
|
|
goos: [ linux ]
|
2020-12-08 16:12:45 +00:00
|
|
|
goarch: [ amd64, arm64 ]
|
2020-10-17 21:13:06 +00:00
|
|
|
runs-on: ${{ matrix.os }}
|
2020-07-04 21:29:03 +00:00
|
|
|
steps:
|
2020-12-15 22:59:06 +00:00
|
|
|
- name: Code Checkout
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Setup Go v${{ matrix.go }}
|
|
|
|
uses: actions/setup-go@v2
|
2020-07-04 21:29:03 +00:00
|
|
|
with:
|
2020-10-17 21:13:06 +00:00
|
|
|
go-version: ${{ matrix.go }}
|
2020-12-06 23:12:41 +00:00
|
|
|
- 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
|
2022-01-25 02:06:14 +00:00
|
|
|
printf "Git Version: $(git version)\n\n"
|
2020-12-06 23:12:41 +00:00
|
|
|
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)"
|
2022-01-25 02:06:14 +00:00
|
|
|
echo "::set-output name=go_mod_cache::$(go env GOMODCACHE)"
|
2020-12-06 23:12:41 +00:00
|
|
|
- name: Build Cache
|
|
|
|
uses: actions/cache@v2
|
|
|
|
with:
|
2022-01-25 02:06:14 +00:00
|
|
|
key: ${{ runner.os }}-go${{ matrix.go }}-${{ hashFiles('**/go.sum') }}
|
2020-12-06 23:12:41 +00:00
|
|
|
restore-keys: |
|
2022-01-25 02:06:14 +00:00
|
|
|
${{ runner.os }}-go${{ matrix.go }}-
|
|
|
|
path: |
|
|
|
|
${{ steps.env.outputs.go_cache }}
|
|
|
|
${{ steps.env.outputs.go_mod_cache }}
|
2020-12-06 23:12:41 +00:00
|
|
|
- name: Get Dependencies
|
|
|
|
run: |
|
|
|
|
go get -v -t -d ./...
|
2020-07-04 21:29:03 +00:00
|
|
|
- name: Build
|
2020-10-17 21:13:06 +00:00
|
|
|
env:
|
|
|
|
GOOS: ${{ matrix.goos }}
|
|
|
|
GOARCH: ${{ matrix.goarch }}
|
2020-11-08 06:42:55 +00:00
|
|
|
CGO_ENABLED: 0
|
2020-12-06 23:12:41 +00:00
|
|
|
SRC_PATH: github.com/pterodactyl/wings
|
2020-10-17 20:52:38 +00:00
|
|
|
run: |
|
2020-12-06 23:12:41 +00:00
|
|
|
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
|
2020-12-15 22:59:06 +00:00
|
|
|
upx build/wings_${{ matrix.goos }}_${{ matrix.goarch }}
|
|
|
|
chmod +x build/wings_${{ matrix.goos }}_${{ matrix.goarch }}
|
2022-01-25 02:06:14 +00:00
|
|
|
- name: Tests
|
2020-07-04 21:29:03 +00:00
|
|
|
run: go test ./...
|
2022-01-25 02:06:14 +00:00
|
|
|
- name: Tests (Race)
|
|
|
|
run: go test -race ./...
|
2020-12-15 22:59:06 +00:00
|
|
|
- name: Upload Artifact
|
|
|
|
uses: actions/upload-artifact@v2
|
2021-09-14 04:48:50 +00:00
|
|
|
if: ${{ github.ref == 'refs/heads/develop' || github.event_name == 'pull_request' }}
|
2020-10-17 20:52:38 +00:00
|
|
|
with:
|
2020-10-17 21:13:06 +00:00
|
|
|
name: wings_${{ matrix.goos }}_${{ matrix.goarch }}
|
|
|
|
path: build/wings_${{ matrix.goos }}_${{ matrix.goarch }}
|