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:
|
2023-10-09 12:46:36 +00:00
|
|
|
- uses: actions/checkout@v4
|
2024-07-03 14:12:13 +00:00
|
|
|
- {uses: actions/setup-go@v5, with: {go-version-file: go.mod}}
|
2024-06-02 09:07:46 +00:00
|
|
|
- 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:
|
2023-10-09 12:46:36 +00:00
|
|
|
- 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:
|
2023-10-09 12:46:36 +00:00
|
|
|
- uses: actions/checkout@v4
|
2024-07-03 14:12:13 +00:00
|
|
|
- {uses: actions/setup-go@v5, with: {go-version-file: go.mod}}
|
2023-02-02 09:09:29 +00:00
|
|
|
- {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
|
2021-04-21 20:53:59 +00:00
|
|
|
test -f ./out/noise/404.html
|
2021-04-28 08:08:24 +00:00
|
|
|
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
|
2023-04-17 11:06:28 +00:00
|
|
|
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:
|
2023-10-09 12:46:36 +00:00
|
|
|
- uses: actions/checkout@v4
|
2023-02-02 09:09:29 +00:00
|
|
|
- {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
|