Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: build

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
go: [ '1.17', '1.18' ]
name: go build with ${{ matrix.go }}
steps:
- uses: actions/checkout@v3

- name: Setup go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go }}

- name: Vet
run: go vet ./...

- name: Build
run: go build -v ./...

- name: Test
run: go test -v ./... -race

tag:
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
name: Tag
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Create tag
uses: actions/github-script@v5
with:
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/v1.0.${{ github.run_number }}',
sha: context.sha
})
53 changes: 13 additions & 40 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,49 +1,22 @@
name: test

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
go: [ '1.17', '1.18' ]
name: go build with ${{ matrix.go }}
steps:
- uses: actions/checkout@v3

- name: Setup go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go }}

- name: Vet
run: go vet ./...

- name: Build
run: go build -v ./...

- name: Test
run: go test -v ./... -race

tag:
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
name: Tag
needs: build
runs-on: ubuntu-latest
test:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v3
- name: Create tag
uses: actions/github-script@v5
with:
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/v1.0.${{ github.run_number }}',
sha: context.sha
})
- name: Build the stack
run: docker-compose up -d
- name: Test Hello
run: |
docker run --network container:scorekeeper-api appropriate/curl -s --retry 10 --retry-connrefused http://localhost:3000/hello
- name: Test Trial
run: |
docker run --network container:scorekeeper-api appropriate/curl -s --retry 10 --retry-connrefused \
-H 'Content-Type: application/json' -d '{"action": "hop", "time": 100}' -X POST http://localhost:3000/scores/trial && \
curl -s http://localhost:3000/scores/trial/average | grep "hop"