Skip to content

Commit 765b045

Browse files
authored
Refactor CI and CQ
2 parents 772f91b + 65fe061 commit 765b045

2 files changed

Lines changed: 82 additions & 53 deletions

File tree

.github/workflows/ci.yml

Lines changed: 20 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,29 @@
11
name: CI
22

33
on:
4-
push: {}
5-
pull_request: {}
4+
push:
5+
pull_request:
66

77
jobs:
8-
go:
9-
name: Go fmt, lint, build and test
8+
Go:
109
runs-on: ubuntu-latest
10+
defaults:
11+
run: { working-directory: backend }
1112
steps:
12-
- name: check out code
13-
uses: actions/checkout@v4
14-
15-
- name: set up go
16-
uses: actions/setup-go@v5
17-
with:
18-
go-version: "1.24.4"
19-
20-
- name: Cache Go modules
21-
uses: actions/cache@v4
22-
with:
23-
path: ~/.cache/go-build
24-
key: ${{ runner.os }}-go-${{ hashFiles('backend/go.sum') }}
25-
restore-keys: ${{ runner.os }}-go-
26-
27-
- name: go fmt
28-
working-directory: backend
29-
run: go fmt ./...
30-
31-
- name: get dependencies
32-
working-directory: backend
33-
run: go mod download
34-
35-
- name: check go.mod is tidy
36-
working-directory: backend
37-
run: |
38-
go mod tidy
39-
git diff --exit-code go.mod go.sum
40-
41-
- name: Run golangci-lint
42-
uses: golangci/golangci-lint-action@v8
43-
with:
44-
version: v2.1.0
45-
working-directory: backend
46-
47-
- name: run tests
48-
working-directory: backend
49-
run: go test ./...
50-
51-
shell-lint:
52-
name: Shell script linting
13+
- uses: actions/checkout@v6
14+
- uses: actions/setup-go@v6
15+
with: { go-version-file: backend/go.mod, cache-dependency-path: backend/go.sum, cache: true }
16+
- run: go fmt ./...
17+
- run: go mod download
18+
- run: go mod verify
19+
- run: go mod tidy; git diff --exit-code go.mod go.sum
20+
- uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9
21+
with: { working-directory: backend }
22+
- run: go test -race -v ./...
23+
24+
Shell:
5325
runs-on: ubuntu-latest
5426
steps:
55-
- name: Checkout code
56-
uses: actions/checkout@v4
57-
58-
- name: Install shellcheck
59-
run: sudo apt-get update && sudo apt-get install -y shellcheck
60-
61-
- name: Run shellcheck
62-
run: shellcheck $(find . -type f -name '*.sh' -not -path '*/site-packages/*' -not -path '*/vendor/*' -not -path '*/node_modules/*')
27+
- uses: actions/checkout@v6
28+
- run: sudo apt-get update && sudo apt-get install -y shellcheck
29+
- run: shellcheck $(find . -type f -name '*.sh' -not -path '*/site-packages/*' -not -path '*/vendor/*' -not -path '*/node_modules/*')

.github/workflows/cq.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Code Quality
2+
3+
on:
4+
push: { branches: [main] }
5+
pull_request: { branches: [main] }
6+
workflow_dispatch:
7+
schedule: [cron: "30 4 * * *"]
8+
9+
concurrency:
10+
group: codeql-${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
permissions: read-all
14+
15+
jobs:
16+
Actions:
17+
runs-on: ubuntu-latest
18+
timeout-minutes: 10
19+
permissions: { security-events: write }
20+
steps:
21+
- uses: actions/checkout@v6
22+
- uses: github/codeql-action/init@v4
23+
with: { languages: actions, build-mode: none, queries: security-and-quality }
24+
- uses: github/codeql-action/analyze@v4
25+
with: { category: "/language:actions" }
26+
27+
Go:
28+
runs-on: ubuntu-latest
29+
timeout-minutes: 10
30+
permissions: { security-events: write }
31+
steps:
32+
- uses: actions/checkout@v6
33+
- uses: actions/setup-go@v6
34+
with: { go-version-file: go.mod, cache: true }
35+
- run: go mod download
36+
- run: go build ./...
37+
- uses: github/codeql-action/init@v4
38+
with: { languages: go, build-mode: autobuild, queries: security-and-quality }
39+
- uses: github/codeql-action/analyze@v4
40+
with: { category: "/language:go" }
41+
42+
JavaScript:
43+
runs-on: ubuntu-latest
44+
timeout-minutes: 10
45+
permissions: { security-events: write }
46+
steps:
47+
- uses: actions/checkout@v6
48+
- uses: github/codeql-action/init@v4
49+
with: { languages: javascript-typescript, build-mode: none, queries: security-and-quality }
50+
- uses: github/codeql-action/analyze@v4
51+
with: { category: "/language:javascript-typescript" }
52+
53+
Python:
54+
runs-on: ubuntu-latest
55+
timeout-minutes: 10
56+
permissions: { security-events: write }
57+
steps:
58+
- uses: actions/checkout@v6
59+
- uses: github/codeql-action/init@v4
60+
with: { languages: python, build-mode: none, queries: security-and-quality }
61+
- uses: github/codeql-action/analyze@v4
62+
with: { category: "/language:python" }

0 commit comments

Comments
 (0)