Skip to content

Commit d536d4d

Browse files
committed
chore(ci): set up CI tests
1 parent 44b0920 commit d536d4d

File tree

3 files changed

+97
-26
lines changed

3 files changed

+97
-26
lines changed

.github/workflows/test.yaml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
---
2+
name: Test
3+
4+
on:
5+
push:
6+
branches:
7+
- main
8+
pull_request:
9+
branches:
10+
- main
11+
12+
permissions:
13+
pull-requests: write
14+
contents: read
15+
16+
jobs:
17+
tests:
18+
runs-on: ubuntu-latest
19+
timeout-minutes: 5
20+
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
lfs: true
27+
28+
- name: Fetch and checkout LFS objects
29+
run: |
30+
git lfs fetch --all
31+
git lfs checkout
32+
33+
- uses: jdx/mise-action@v3
34+
with:
35+
install: true
36+
37+
- name: Run pre-commit
38+
run: mise run pre-commit
39+
40+
- name: Format
41+
run: |
42+
mise run fmt
43+
git diff --exit-code || (echo "Code is not formatted, run 'mise run fmt' locally" && exit 1)
44+
45+
- name: Lint
46+
run: mise run lint
47+
48+
- name: Unit tests
49+
run: mise run test_unit
50+
51+
- name: End to end tests
52+
run: mise run test_e2e
53+
54+
- name: Create coverage artifact
55+
run: mise run coverage
56+
57+
- name: Generate code coverage report
58+
uses: irongut/[email protected]
59+
with:
60+
filename: coverage.xml
61+
badge: false
62+
fail_below_min: false
63+
format: markdown
64+
hide_branch_rate: false
65+
hide_complexity: true
66+
indicators: true
67+
output: both
68+
69+
- name: Add Coverage PR Comment
70+
uses: marocchino/sticky-pull-request-comment@v2
71+
if: github.event_name == 'pull_request'
72+
with:
73+
recreate: true
74+
path: code-coverage-results.md

.pre-commit-config.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,8 @@ repos:
2626
rev: v1.35.6
2727
hooks:
2828
- id: typos
29+
- repo: https://github.com/ComPWA/taplo-pre-commit
30+
rev: v0.9.3
31+
hooks:
32+
- id: taplo-format
33+
- id: taplo-lint

mise.toml

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33
_.path = ['{{config_root}}/node_modules/.bin']
44
_.python.venv = { path = "venv", create = true }
55

6+
[settings]
7+
python.compile = false
8+
69
[tools]
710
go = "1.25.3"
811
node = "24.6.0"
9-
python = "3.9.0"
12+
python = "3.9.14"
1013
golangci-lint = "2.4.0"
1114

1215
[tasks."init"]
@@ -39,65 +42,54 @@ depends = ["install:*"]
3942

4043
[tasks."commit-msg"]
4144
description = "Run commit-msg hooks"
42-
run = [
43-
"npx commitlint --edit $1",
44-
]
45+
run = ["npx commitlint --edit $1"]
4546

4647
[tasks."pre-commit"]
4748
description = "Run pre-commit tasks"
48-
run = "pre-commit"
49+
run = "python -m pre_commit"
4950

5051
[tasks."lint"]
51-
run = [
52-
"golangci-lint run",
53-
]
52+
run = ["golangci-lint run"]
5453

5554
[tasks."fmt"]
56-
run = [
57-
"go mod tidy",
58-
"env GOFUMPT_SPLIT_LONG_LINES=on golangci-lint fmt ./...",
59-
]
55+
run = ["go mod tidy", "env GOFUMPT_SPLIT_LONG_LINES=on golangci-lint fmt ./..."]
6056

6157
[tasks."prepush"]
6258
depends = ["fmt", "lint", "test"]
6359

6460
[tasks."test:config"]
65-
run = [
66-
"golangci-lint config verify",
67-
]
61+
run = ["golangci-lint config verify"]
6862

6963
[tasks."regenerate:e2e"]
70-
run = [
71-
"go tool gotestsum -- -v ./test/... --count=1 -update",
72-
]
64+
run = ["go tool gotestsum -- -v ./test/... --count=1 -update"]
7365

7466
[tasks."test"]
7567
depends = ["test:*", "test_unit", "test_e2e"]
7668

7769
[tasks."coverage"]
7870
run = [
79-
"go tool gocovmerge integration.txt unit.txt > coverage.txt",
80-
"go tool cover -html=coverage.txt -o coverage.html",
81-
"go tool gocover-cobertura <coverage.txt >coverage.xml"
71+
"go tool gocovmerge integration.txt unit.txt > coverage.txt",
72+
"go tool cover -html=coverage.txt -o coverage.html",
73+
"go tool gocover-cobertura <coverage.txt >coverage.xml",
8274
]
83-
sources = [ "integration.txt", "unit.txt"]
75+
sources = ["integration.txt", "unit.txt"]
8476
outputs = ["coverage.html", "coverage.xml"]
8577

8678
[tasks.bin-package]
8779
description = "Build bubbletea example package"
8880
run = [
8981
"cd bin/${PACKAGE} && go build -o ./dist/${PACKAGE}",
9082
"mkdir -p ./dist",
91-
"cp bin/${PACKAGE}/dist/${PACKAGE} ./dist/${PACKAGE}"
83+
"cp bin/${PACKAGE}/dist/${PACKAGE} ./dist/${PACKAGE}",
9284
]
93-
outputs = [ "dist/${PACKAGE}" ]
94-
sources = [ "bin/${PACKAGE}/**" ]
85+
outputs = ["dist/${PACKAGE}"]
86+
sources = ["bin/${PACKAGE}/**"]
9587

9688
[tasks.bin]
9789
description = "Build all bubbletea example packages"
9890
run = [
9991
"PACKAGE=editors mise run bin-package",
100-
"PACKAGE=list mise run bin-package"
92+
"PACKAGE=list mise run bin-package",
10193
]
10294
outputs = ["dist/editors", "dist/list"]
10395
sources = ["bin/**"]

0 commit comments

Comments
 (0)