Skip to content

Commit 047a5fd

Browse files
authored
ci: add backwards compatibility tests (#23)
1 parent 0d8262c commit 047a5fd

File tree

5 files changed

+98
-4
lines changed

5 files changed

+98
-4
lines changed

.github/workflows/back-compat-pr.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: back-compat PR
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- "go.*"
7+
- "**/*.go"
8+
- ".github/workflows/*.yml"
9+
10+
permissions:
11+
contents: read
12+
13+
env:
14+
GO_VERSION: '1.22.5'
15+
16+
jobs:
17+
check-back-compat:
18+
name: build
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
- name: Set up Go
23+
uses: actions/setup-go@v5
24+
with:
25+
go-version: ${{ env.GO_VERSION }}
26+
- name: build head
27+
run: |
28+
go build -o omm_head
29+
cp omm_head /var/tmp
30+
- uses: actions/checkout@v4
31+
with:
32+
ref: main
33+
- name: build main
34+
run: |
35+
go build -o omm_main
36+
cp omm_main /var/tmp
37+
- name: Run last version
38+
run: |
39+
/var/tmp/omm_main --db-path=/var/tmp/throwaway.db 'test: a task from main'
40+
- name: Run current version
41+
run: |
42+
/var/tmp/omm_head --db-path=/var/tmp/throwaway.db 'test: a task from PR HEAD'
43+
/var/tmp/omm_head --db-path=/var/tmp/throwaway.db tasks

.github/workflows/back-compat.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: back-compat
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
7+
permissions:
8+
contents: read
9+
10+
env:
11+
GO_VERSION: '1.22.5'
12+
13+
jobs:
14+
check-back-compat:
15+
name: build
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 2
21+
- name: Set up Go
22+
uses: actions/setup-go@v5
23+
with:
24+
go-version: ${{ env.GO_VERSION }}
25+
- name: build head
26+
run: |
27+
go build -o omm_head
28+
cp omm_head /var/tmp
29+
rm omm_head
30+
- run: git checkout HEAD~1
31+
- name: build main
32+
run: |
33+
go build -o omm_prev
34+
cp omm_prev /var/tmp
35+
- name: Run last version
36+
run: |
37+
/var/tmp/omm_prev --db-path=/var/tmp/throwaway.db 'test: a task from previous commit'
38+
- name: Run current version
39+
run: |
40+
/var/tmp/omm_head --db-path=/var/tmp/throwaway.db 'test: a task from main HEAD'
41+
/var/tmp/omm_head --db-path=/var/tmp/throwaway.db tasks

.github/workflows/build.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,8 @@ jobs:
3333
uses: golangci/golangci-lint-action@v6
3434
with:
3535
version: v1.58
36+
- name: run omm
37+
run: |
38+
go build .
39+
./omm 'test: a task'
40+
./omm tasks

cmd/root.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ var (
5050
updateContents string
5151
)
5252

53-
func Execute(version string) {
53+
func Execute(version string) error {
5454
rootCmd, err := NewRootCommand()
5555

5656
rootCmd.Version = version
@@ -59,7 +59,7 @@ func Execute(version string) {
5959
os.Exit(1)
6060
}
6161

62-
_ = rootCmd.Execute()
62+
return rootCmd.Execute()
6363
}
6464

6565
func setupDB(dbPathFull string) (*sql.DB, error) {

main.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package main
22

33
import (
4-
"github.com/dhth/omm/cmd"
4+
"os"
55
"runtime/debug"
6+
7+
"github.com/dhth/omm/cmd"
68
)
79

810
var (
@@ -17,5 +19,8 @@ func main() {
1719
v = info.Main.Version
1820
}
1921
}
20-
cmd.Execute(v)
22+
err := cmd.Execute(v)
23+
if err != nil {
24+
os.Exit(1)
25+
}
2126
}

0 commit comments

Comments
 (0)