Skip to content

Commit

Permalink
ci: add backwards compatibility tests (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhth authored Aug 5, 2024
1 parent 0d8262c commit 047a5fd
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 4 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/back-compat-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: back-compat PR

on:
pull_request:
paths:
- "go.*"
- "**/*.go"
- ".github/workflows/*.yml"

permissions:
contents: read

env:
GO_VERSION: '1.22.5'

jobs:
check-back-compat:
name: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: build head
run: |
go build -o omm_head
cp omm_head /var/tmp
- uses: actions/checkout@v4
with:
ref: main
- name: build main
run: |
go build -o omm_main
cp omm_main /var/tmp
- name: Run last version
run: |
/var/tmp/omm_main --db-path=/var/tmp/throwaway.db 'test: a task from main'
- name: Run current version
run: |
/var/tmp/omm_head --db-path=/var/tmp/throwaway.db 'test: a task from PR HEAD'
/var/tmp/omm_head --db-path=/var/tmp/throwaway.db tasks
41 changes: 41 additions & 0 deletions .github/workflows/back-compat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: back-compat

on:
push:
branches: [ "main" ]

permissions:
contents: read

env:
GO_VERSION: '1.22.5'

jobs:
check-back-compat:
name: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: build head
run: |
go build -o omm_head
cp omm_head /var/tmp
rm omm_head
- run: git checkout HEAD~1
- name: build main
run: |
go build -o omm_prev
cp omm_prev /var/tmp
- name: Run last version
run: |
/var/tmp/omm_prev --db-path=/var/tmp/throwaway.db 'test: a task from previous commit'
- name: Run current version
run: |
/var/tmp/omm_head --db-path=/var/tmp/throwaway.db 'test: a task from main HEAD'
/var/tmp/omm_head --db-path=/var/tmp/throwaway.db tasks
5 changes: 5 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,8 @@ jobs:
uses: golangci/golangci-lint-action@v6
with:
version: v1.58
- name: run omm
run: |
go build .
./omm 'test: a task'
./omm tasks
4 changes: 2 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ var (
updateContents string
)

func Execute(version string) {
func Execute(version string) error {
rootCmd, err := NewRootCommand()

rootCmd.Version = version
Expand All @@ -59,7 +59,7 @@ func Execute(version string) {
os.Exit(1)
}

_ = rootCmd.Execute()
return rootCmd.Execute()
}

func setupDB(dbPathFull string) (*sql.DB, error) {
Expand Down
9 changes: 7 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package main

import (
"github.com/dhth/omm/cmd"
"os"
"runtime/debug"

"github.com/dhth/omm/cmd"
)

var (
Expand All @@ -17,5 +19,8 @@ func main() {
v = info.Main.Version
}
}
cmd.Execute(v)
err := cmd.Execute(v)
if err != nil {
os.Exit(1)
}
}

0 comments on commit 047a5fd

Please sign in to comment.