Skip to content

Commit

Permalink
add test job to workflow 🤪
Browse files Browse the repository at this point in the history
  • Loading branch information
benleb committed Jul 25, 2023
1 parent ecf92a0 commit 5aacf31
Showing 1 changed file with 67 additions and 52 deletions.
119 changes: 67 additions & 52 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,58 +1,73 @@
name: build

on:
push: { branches: [master, main, dev/*], tags: [v*] }
pull_request:
workflow_dispatch:
push: { branches: [master, main, dev/*], tags: [v*] }
pull_request:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
permissions: { contents: write, packages: write }

# cancel already in-progress jobs or runs for the current workflow
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
REGISTRY: ghcr.io
TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}

steps:
- name: Checkout
uses: actions/checkout@v3
with: { fetch-depth: 0 }

- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Go
uses: actions/setup-go@v4
with: { cache: true, check-latest: true, go-version-file: "go.mod" }

- name: Run GoReleaser (snapshot)
uses: goreleaser/goreleaser-action@v4
if: "!startsWith(github.ref, 'refs/tags/')"
with:
version: latest
args: build --clean --snapshot
env:
REGISTRY: ${{ env.REGISTRY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Run GoReleaser (release)
uses: goreleaser/goreleaser-action@v4
if: startsWith(github.ref, 'refs/tags/')
with:
version: latest
args: release --clean
build:
runs-on: ubuntu-latest
permissions: { contents: write, packages: write }

# cancel already in-progress jobs or runs for the current workflow
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
REGISTRY: ${{ env.REGISTRY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
REGISTRY: ghcr.io
TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}

steps:
- name: Checkout
uses: actions/checkout@v3
with: { fetch-depth: 0 }

- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Go
uses: actions/setup-go@v4
with: { cache: true, check-latest: true, go-version-file: "go.mod" }

- name: Run GoReleaser (snapshot)
uses: goreleaser/goreleaser-action@v4
if: "!startsWith(github.ref, 'refs/tags/')"
with:
version: latest
args: build --clean --snapshot
env:
REGISTRY: ${{ env.REGISTRY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Run GoReleaser (release)
uses: goreleaser/goreleaser-action@v4
if: startsWith(github.ref, 'refs/tags/')
with:
version: latest
args: release --clean
env:
REGISTRY: ${{ env.REGISTRY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}

test:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: ["1.19", "1.20"]

steps:
- name: Test with Go
run: go test -json > TestResults-${{ matrix.go-version }}.json
- name: Upload Go test results
uses: actions/upload-artifact@v3
with:
name: Go-results-${{ matrix.go-version }}
path: TestResults-${{ matrix.go-version }}.json

0 comments on commit 5aacf31

Please sign in to comment.