tests: making tests just much better #97
Workflow file for this run
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
# This workflow will build a golang project | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go | |
name: test-and-publish-version-dev | |
on: | |
push: | |
branches-ignore: | |
- main | |
jobs: | |
test: | |
environment: Development | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
go-version: [ '1.21', '1.22.x' ] | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: satackey/action-docker-layer-caching@v0.0.11 | |
continue-on-error: true | |
- name: Set database running | |
uses: supercharge/mongodb-github-action@1.9.0 | |
with: | |
mongodb-username: admin | |
mongodb-password: p4ssw0rd | |
mongodb-db: valhalla-test | |
mongodb-port: 27017 | |
- name: Create env file | |
run: cp test.env .env | |
- name: Run tests | |
run: go test -v ./... | |
build: | |
environment: Development | |
runs-on: ubuntu-latest | |
needs: test | |
steps: | |
- uses: actions/checkout@v3 | |
# Read version from file | |
- name: Read version | |
id: version | |
run: echo ::set-output name=version::$(cat version.config) | |
# Read date in format YYYYMMDDHHMMSS | |
- name: Read date | |
id: date | |
run: echo ::set-output name=date::$(date +"%Y%m%d%H%M%S") | |
# Read branch name | |
- name: Read branch name | |
id: branch | |
run: echo ::set-output name=branch::${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}} | |
# Set up Go | |
- name: Set up Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: 1.22.0 | |
# Create tag with version, date and branch | |
- 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/${{ steps.version.outputs.version }}-${{ steps.date.outputs.date }}-${{ steps.branch.outputs.branch }}', | |
sha: context.sha | |
}) |