-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move the CI from Travis to GitHub Actions (#17)
This change makes the CI to be run by GitHub Actions instead of Travis. This is a lot less flaky and a tad bit faster. This also automates the release process and builds the artifacts so that I don't have to run a weird script on my machine every time.
- Loading branch information
Showing
3 changed files
with
163 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
name: CI | ||
|
||
on: | ||
pull_request: {} | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
|
||
test: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
go: | ||
- 1.13 | ||
- 1.14 | ||
name: Go ${{ matrix.go }} | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: ${{ matrix.go }} | ||
id: go | ||
|
||
- name: Install golint | ||
run: go install golang.org/x/lint/golint | ||
|
||
- name: Install git2go | ||
run: | | ||
export GOPATH="$(go env GOPATH)" | ||
go mod edit -replace "github.com/lhchavez/git2go/v29=${GOPATH}/src/github.com/lhchavez/git2go" | ||
git clone --recurse-submodules https://github.com/lhchavez/git2go "${GOPATH}/src/github.com/lhchavez/git2go" | ||
go get -d github.com/lhchavez/git2go/v29 | ||
(cd "${GOPATH}/src/github.com/lhchavez/git2go/" && ./script/build-libgit2-static.sh) | ||
- name: Lint | ||
run: golint -set_exit_status ./... | ||
|
||
- name: Get dependencies | ||
run: go get -tags=static -t -v ./... | ||
|
||
- name: Vet | ||
run: go vet -tags=static -v ./... | ||
|
||
- name: Test | ||
run: go test -tags=static -v -race -coverprofile=coverage.txt -covermode=atomic ./... | ||
|
||
- name: Ensure formatting | ||
run: | | ||
if [[ $(git ls-tree -r HEAD^{tree} . --full-name --name-only | \ | ||
grep '\.go$' | \ | ||
xargs -n 1 gofmt -d | \ | ||
wc -c) -ne 0 \ | ||
]]; then | ||
echo "please run gofmt on all the files" | ||
exit 1 | ||
fi | ||
- name: Upload code coverage | ||
run: bash <(curl -s https://codecov.io/bash) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
tags: | ||
- v* | ||
|
||
jobs: | ||
|
||
release: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.13 | ||
id: go | ||
|
||
- name: Install git2go | ||
run: | | ||
export GOPATH="$(go env GOPATH)" | ||
go mod edit -replace "github.com/lhchavez/git2go/v29=${GOPATH}/src/github.com/lhchavez/git2go" | ||
git clone --recurse-submodules https://github.com/lhchavez/git2go "${GOPATH}/src/github.com/lhchavez/git2go" | ||
go get -d github.com/lhchavez/git2go/v29 | ||
(cd "${GOPATH}/src/github.com/lhchavez/git2go/" && ./script/build-libgit2-static.sh) | ||
- name: Get dependencies | ||
run: go get -tags=static -t -v ./... | ||
|
||
- name: Bump version and push tag | ||
id: bump-version | ||
uses: anothrNick/github-tag-action@c170e78287f338a4af0dc49e033e50e5a072d82b | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
WITH_V: true | ||
DEFAULT_BUMP: patch | ||
INITIAL_VERSION: 1.0.0 | ||
|
||
- name: Build | ||
run: | | ||
mkdir -p artifacts/backend/usr/bin/ | ||
go build -o artifacts/backend/usr/bin/omegaup-grader \ | ||
-ldflags "-X main.ProgramVersion=${{ steps.bump-version.outputs.tag }}" \ | ||
-tags=static \ | ||
github.com/omegaup/quark/cmd/omegaup-grader | ||
go build -o artifacts/backend/usr/bin/omegaup-broadcaster \ | ||
-ldflags "-X main.ProgramVersion=${{ steps.bump-version.outputs.tag }}" \ | ||
-tags=static \ | ||
github.com/omegaup/quark/cmd/omegaup-broadcaster | ||
mkdir -p artifacts/runner/usr/bin/ | ||
go build -o artifacts/runner/usr/bin/omegaup-runner \ | ||
-ldflags "-X main.ProgramVersion=${{ steps.bump-version.outputs.tag }}" \ | ||
-tags=static \ | ||
github.com/omegaup/quark/cmd/omegaup-runner | ||
- name: Package | ||
run: | | ||
tar -cJf omegaup-backend.tar.xz --owner=root:0 --group=root:0 -C artifacts/backend/ . | ||
tar -cJf omegaup-runner.tar.xz --owner=root:0 --group=root:0 -C artifacts/runner/ . | ||
- name: Create Release | ||
id: create-release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ steps.bump-version.outputs.tag }} | ||
release_name: ${{ steps.bump-version.outputs.tag }} | ||
draft: false | ||
prerelease: false | ||
|
||
- name: Upload omegaup-backend.tar.xz Release Asset | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create-release.outputs.upload_url }} | ||
asset_path: ./omegaup-backend.tar.xz | ||
asset_name: omegaup-backend.tar.xz | ||
asset_content_type: application/octet-stream | ||
|
||
- name: Upload omegaup-runner.tar.xz Release Asset | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create-release.outputs.upload_url }} | ||
asset_path: ./omegaup-runner.tar.xz | ||
asset_name: omegaup-runner.tar.xz | ||
asset_content_type: application/octet-stream |
This file was deleted.
Oops, something went wrong.