error-pages/.github/workflows/tests.yml

93 lines
2.9 KiB
YAML
Raw Normal View History

2024-07-03 14:12:13 +00:00
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
# docs: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions
name: 🧪 Tests
2020-07-08 11:12:21 +00:00
on:
push:
2021-09-29 15:38:50 +00:00
branches: [master, main]
tags-ignore: ['**']
paths-ignore: ['**.md']
2020-07-08 11:12:21 +00:00
pull_request:
2021-09-29 15:38:50 +00:00
paths-ignore: ['**.md']
2020-07-08 11:12:21 +00:00
2022-06-12 08:38:17 +00:00
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
2024-07-03 14:12:13 +00:00
jobs:
2021-04-13 13:55:03 +00:00
gitleaks:
2024-07-03 14:12:13 +00:00
name: Check for GitLeaks
2023-02-23 17:50:20 +00:00
runs-on: ubuntu-latest
2021-04-13 13:55:03 +00:00
steps:
2024-07-03 14:12:13 +00:00
- {uses: actions/checkout@v4, with: {fetch-depth: 0}}
- uses: gacts/gitleaks@v1
2021-09-29 15:38:50 +00:00
golangci-lint:
2024-07-03 14:12:13 +00:00
name: Run golangci-lint
2023-02-23 17:50:20 +00:00
runs-on: ubuntu-latest
2021-09-29 15:38:50 +00:00
steps:
- uses: actions/checkout@v4
2024-07-03 14:12:13 +00:00
- {uses: actions/setup-go@v5, with: {go-version-file: go.mod}}
- uses: golangci/golangci-lint-action@v6
2022-03-28 11:04:23 +00:00
2021-09-29 15:38:50 +00:00
go-test:
name: Unit tests
2023-02-23 17:50:20 +00:00
runs-on: ubuntu-latest
2021-09-29 15:38:50 +00:00
steps:
- uses: actions/checkout@v4
2024-07-03 14:12:13 +00:00
- {uses: actions/setup-go@v5, with: {go-version-file: go.mod}}
- run: go test -race ./...
2021-09-29 15:38:50 +00:00
build:
name: Build for ${{ matrix.os }} (${{ matrix.arch }})
2023-02-23 17:50:20 +00:00
runs-on: ubuntu-latest
2021-09-29 15:38:50 +00:00
strategy:
fail-fast: false
matrix:
2024-07-03 14:12:13 +00:00
os: [linux, darwin, windows] # freebsd
arch: [amd64, arm64] # 386
needs: [golangci-lint, go-test]
2020-07-08 11:12:21 +00:00
steps:
- uses: actions/checkout@v4
2024-07-03 14:12:13 +00:00
- {uses: actions/setup-go@v5, with: {go-version-file: go.mod}}
- {uses: gacts/github-slug@v1, id: slug}
2024-07-03 14:12:13 +00:00
- env:
2021-09-29 15:38:50 +00:00
GOOS: ${{ matrix.os }}
GOARCH: ${{ matrix.arch }}
CGO_ENABLED: 0
2024-07-03 14:12:13 +00:00
LDFLAGS: -s -w -X gh.tarampamp.am/error-pages/internal/appmeta.version=${{ steps.slug.outputs.commit-hash-short }}
2021-09-29 15:38:50 +00:00
run: go build -trimpath -ldflags "$LDFLAGS" -o ./error-pages ./cmd/error-pages/
2024-07-03 14:12:13 +00:00
- if: matrix.os == 'linux' && matrix.arch == 'amd64'
2023-01-29 10:54:56 +00:00
run: ./error-pages --version && ./error-pages -h
2024-07-03 14:12:13 +00:00
- if: matrix.os == 'linux' && matrix.arch == 'amd64'
run: mkdir ./out && ./error-pages --log-level=debug build --index --target-dir ./out
- if: matrix.os == 'linux' && matrix.arch == 'amd64'
2021-04-13 13:55:03 +00:00
run: |
test -f ./out/index.html
test -f ./out/ghost/404.html
2024-07-03 14:12:13 +00:00
test -f ./out/l7/404.html
2021-04-13 13:55:03 +00:00
test -f ./out/shuffle/404.html
test -f ./out/noise/404.html
test -f ./out/hacker-terminal/404.html
2021-10-15 05:32:31 +00:00
test -f ./out/cats/404.html
2022-02-22 15:48:55 +00:00
test -f ./out/lost-in-space/404.html
2022-03-20 06:32:40 +00:00
test -f ./out/app-down/404.html
2022-03-22 18:31:33 +00:00
test -f ./out/connection/404.html
test -f ./out/orient/404.html
2020-07-08 11:12:21 +00:00
2021-09-29 15:38:50 +00:00
docker-image:
2024-07-03 14:12:13 +00:00
name: Build the docker image
2023-02-23 17:50:20 +00:00
runs-on: ubuntu-latest
2024-07-03 14:12:13 +00:00
needs: [golangci-lint, go-test]
2021-09-29 15:38:50 +00:00
steps:
- uses: actions/checkout@v4
- {uses: gacts/github-slug@v1, id: slug}
2024-07-03 14:12:13 +00:00
- uses: docker/build-push-action@v6
2021-09-29 15:38:50 +00:00
with:
context: .
file: Dockerfile
push: false
2024-07-03 14:12:13 +00:00
build-args: "APP_VERSION=${{ steps.slug.outputs.commit-hash-short }}"
2021-09-29 15:38:50 +00:00
tags: app:ci