Skip to content

Commit

Permalink
Add CI config
Browse files Browse the repository at this point in the history
  • Loading branch information
AlekSi committed Aug 20, 2024
1 parent 706398f commit 41577d2
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 11 deletions.
60 changes: 49 additions & 11 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
---
name: Linters
name: Go
on:
push:
branches:
- main
pull_request:
types:
- unlabeled # if GitHub Actions stuck, add and remove "not ready" label to force rebuild
- opened
- reopened
- synchronize
push:
branches:
- main
schedule:
- cron: "12 3 * * *"

# Do not run this job in parallel for any PR change or branch push.
concurrency:
group: ${{ github.workflow }}-golangci-lint-${{ github.head_ref || github.ref_name }}
cancel-in-progress: true

env:
GOPATH: /home/runner/go
GOCACHE: /home/runner/go/cache
Expand All @@ -27,6 +22,50 @@ env:
GOTOOLCHAIN: local

jobs:
tests:
name: Tests
runs-on: ubuntu-22.04
timeout-minutes: 10

# Do not run this job in parallel for any PR change or branch push.
concurrency:
group: ${{ github.workflow }}-tests-${{ github.head_ref || github.ref_name }}
cancel-in-progress: true

if: github.event_name != 'pull_request' || !contains(github.event.pull_request.labels.*.name, 'not ready')

steps:
# TODO https://github.com/FerretDB/github-actions/issues/211
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Go
uses: FerretDB/github-actions/setup-go@main
with:
cache-key: tests

- name: Install Task
run: go generate -x
working-directory: tools

- name: Run init
run: bin/task init

- name: Run tests
run: bin/task tests
env:
GOFLAGS: ${{ runner.debug == '1' && '-v' || '' }}

# we don't want them on CI
- name: Clean test and fuzz caches
if: always()
run: go clean -testcache -fuzzcache

- name: Check dirty
run: |
git status
git diff --exit-code
linters:
name: linters
runs-on: ubuntu-22.04
Expand All @@ -45,12 +84,11 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0 # for `golangci-lint run --new` to work
lfs: false # LFS is used only by website

- name: Setup Go
uses: FerretDB/github-actions/setup-go@main
with:
cache-key: lint
cache-key: linters

- name: Run linters
uses: FerretDB/github-actions/linters@main
Expand Down
6 changes: 6 additions & 0 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ version: "3"
vars:
DB: ""
CONFIG: ""
RACE_FLAG: -race={{and (ne OS "windows") (ne ARCH "arm") (ne ARCH "riscv64")}}

tasks:
init-tools:
Expand Down Expand Up @@ -64,6 +65,11 @@ tasks:
cmds:
- go build -v -o bin/ ./cmd/dance/

test:
desc: "Run unit tests (with caching)"
cmds:
- go test {{.RACE_FLAG}} -shuffle=on ./internal/...

dance:
desc: "Dance!"
deps: [build]
Expand Down

0 comments on commit 41577d2

Please sign in to comment.