Skip to content

Commit

Permalink
CI workflow (#65)
Browse files Browse the repository at this point in the history
* CI workflow

* fix upper branch name

* fix

* start postgres

* remove workflows

* upgrade crust
  • Loading branch information
wojtek-coreum authored Apr 29, 2024
1 parent a3cd22b commit ed49d38
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 142 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: ci
on:
push:
branches: [ chains/coreum ]
pull_request:
branches: [ chains/coreum ]
schedule:
- cron: '0 1 * * 1' # At 01:00 on Monday
workflow_dispatch:

jobs:
ci:
strategy:
fail-fast: false
matrix:
ci_step: [
"test",
]
include:
- ci_step: "test"
command: |
docker run --name bdjuno-test-db -e POSTGRES_USER=bdjuno -e POSTGRES_PASSWORD=password -e POSTGRES_DB=bdjuno -d -p 6433:5432 postgres
bdjuno-builder test
linter-cache: false
codecov: true
codecov-name: coreum

runs-on: ubuntu-22.04
steps:
- name: Go version used to build builder
run: go version
- name: Checkout bdjuno
uses: actions/checkout@v4
with:
persist-credentials: false
path: bdjuno
- name: Set up build system
run: |
echo "$(pwd)/bdjuno/bin" >> $GITHUB_PATH
- name: Retrieve go version
id: goversion
run: echo "GO_VERSION=$(bdjuno/bin/go version)" >> $GITHUB_OUTPUT
- name: Print go version
run: echo ${{ steps.goversion.outputs.GO_VERSION }}
- name: Setup go cache
uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-v2-${{ hashFiles('**/go.sum') }}-${{ steps.goversion.outputs.GO_VERSION }}
- name: Prepare dependencies
run: |
bdjuno-builder build/me
bdjuno-builder download
- name: Run ${{ matrix.ci_step }}
run: ${{ matrix.command }}
39 changes: 0 additions & 39 deletions .github/workflows/lint.yml

This file was deleted.

49 changes: 0 additions & 49 deletions .github/workflows/test.yml

This file was deleted.

5 changes: 5 additions & 0 deletions build/bdjuno/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ func Tidy(ctx context.Context, deps build.DepsFunc) error {
return golang.Tidy(ctx, repoPath, deps)
}

// DownloadDependencies downloads go dependencies.
func DownloadDependencies(ctx context.Context, deps build.DepsFunc) error {
return golang.DownloadDependencies(ctx, repoPath, deps)
}

// Test run unit tests in bdjuno repo.
func Test(ctx context.Context, deps build.DepsFunc) error {
return golang.Test(ctx, repoPath, deps)
Expand Down
28 changes: 1 addition & 27 deletions build/cmd/main.go
Original file line number Diff line number Diff line change
@@ -1,36 +1,10 @@
package main

import (
"context"
"os"
"path/filepath"

selfBuild "github.com/CoreumFoundation/bdjuno/build"
"github.com/CoreumFoundation/coreum-tools/pkg/build"
"github.com/CoreumFoundation/coreum-tools/pkg/logger"
"github.com/CoreumFoundation/coreum-tools/pkg/must"
"github.com/CoreumFoundation/coreum-tools/pkg/run"
)

func main() {
run.Tool("build", func(ctx context.Context) error {
flags := logger.Flags(logger.ToolDefaultConfig, "build")
if err := flags.Parse(os.Args[1:]); err != nil {
return err
}
exec := build.NewExecutor(selfBuild.Commands)
if build.Autocomplete(exec) {
return nil
}

changeWorkingDir()
return build.Do(ctx, "bdjuno", flags.Args(), exec)
})
}

// changeWorkingDir sets working dir to the root directory of repository.
func changeWorkingDir() {
must.OK(os.Chdir(filepath.Dir(filepath.Dir(filepath.Dir(must.String(
filepath.EvalSymlinks(must.String(os.Executable())),
))))))
build.Main(selfBuild.Commands)
}
15 changes: 5 additions & 10 deletions build/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,20 @@ module github.com/CoreumFoundation/bdjuno/build
go 1.21

require (
github.com/CoreumFoundation/coreum-tools v0.4.1-0.20230627094203-821c6a4eebab
github.com/CoreumFoundation/crust/build v0.0.0-20240221111501-24517d1ac71b
github.com/CoreumFoundation/coreum-tools v0.4.1-0.20240321120602-0a9c50facc68
github.com/CoreumFoundation/crust/build v0.0.0-20240426160154-ef0a4b5d93ea
)

require (
github.com/CoreumFoundation/coreum/v4 v4.0.0-20240213123712-d7d6a45ddb8f // indirect
github.com/iancoleman/strcase v0.3.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/mod v0.12.0 // indirect
)

require (
github.com/samber/lo v1.39.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.24.0 // indirect
// Make sure to not bump x/exp dependency without cosmos-sdk updated because their breaking change is not compatible
// with cosmos-sdk v0.47.
// Details: https://github.com/cosmos/cosmos-sdk/issues/18415
golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1 // indirect
golang.org/x/mod v0.12.0 // indirect
)
12 changes: 4 additions & 8 deletions build/go.sum
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
github.com/CoreumFoundation/coreum-tools v0.4.1-0.20230627094203-821c6a4eebab h1:XPcSzlQ06tor/py1LkEM9FX70LIeDWB++vLuAO6eAYI=
github.com/CoreumFoundation/coreum-tools v0.4.1-0.20230627094203-821c6a4eebab/go.mod h1:VD93vCHkxYaT/RhOesXTFgd/GQDW54tr0BqGi5JU1c0=
github.com/CoreumFoundation/coreum/v4 v4.0.0-20240213123712-d7d6a45ddb8f h1:a+lBcN3rWvoa/5mvdOQMaUU604/J3h/0rumGnISRglo=
github.com/CoreumFoundation/coreum/v4 v4.0.0-20240213123712-d7d6a45ddb8f/go.mod h1:m17GEOObKO0uMNRSeitPFjjne55MSbzFeTlAONaMGkI=
github.com/CoreumFoundation/crust/build v0.0.0-20240221111501-24517d1ac71b h1:IoQS6FhpOHVKc+xnzNCUYwdIL59CPTgsXKNYlcjVetY=
github.com/CoreumFoundation/crust/build v0.0.0-20240221111501-24517d1ac71b/go.mod h1:7g0+guH6BZLfm8oVJwwgCr8ntzIwJAQo7MC1c5wMFBo=
github.com/CoreumFoundation/coreum-tools v0.4.1-0.20240321120602-0a9c50facc68 h1:Tb9avuSQW3smVGrUnDh/Y+ML4eK802UsvJNZHsBgOGg=
github.com/CoreumFoundation/coreum-tools v0.4.1-0.20240321120602-0a9c50facc68/go.mod h1:VD93vCHkxYaT/RhOesXTFgd/GQDW54tr0BqGi5JU1c0=
github.com/CoreumFoundation/crust/build v0.0.0-20240426160154-ef0a4b5d93ea h1:Rk0szAREKByOwg8M+yfg8snu6C2OdP7KjIznrIEk38o=
github.com/CoreumFoundation/crust/build v0.0.0-20240426160154-ef0a4b5d93ea/go.mod h1:nS+zNTGtsK9ComEW/McsAK4XnPLhTsf0wIN5o1grD98=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/benbjohnson/clock v1.3.5 h1:VvXlSJBzZpA/zum6Sj74hxwYI2DIxRWuNIoXAzHZz5o=
github.com/benbjohnson/clock v1.3.5/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI=
github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
Expand Down
19 changes: 10 additions & 9 deletions build/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@ import (
)

// Commands is a definition of commands available in build system.
var Commands = map[string]build.CommandFunc{
"build/me": crust.BuildBuilder,
"build": bdjuno.Build,
"images": func(ctx context.Context, deps build.DepsFunc) error {
var Commands = map[string]build.Command{
"build/me": {Fn: crust.BuildBuilder, Description: "Builds the builder"},
"build": {Fn: bdjuno.Build, Description: "Builds bdjuno binary"},
"download": {Fn: bdjuno.DownloadDependencies, Description: "Downloads go dependencies"},
"images": {Fn: func(ctx context.Context, deps build.DepsFunc) error {
deps(bdjuno.BuildDockerImage, hasura.BuildDockerImage)
return nil
},
"images/bdjuno": bdjuno.BuildDockerImage,
"images/hasura": hasura.BuildDockerImage,
"test": bdjuno.Test,
"tidy": bdjuno.Tidy,
}, Description: "Builds bdjuno and hasura docker images"},
"images/bdjuno": {Fn: bdjuno.BuildDockerImage, Description: "Builds bdjuno image"},
"images/hasura": {Fn: hasura.BuildDockerImage, Description: "Builds hasura docker image"},
"test": {Fn: bdjuno.Test, Description: "Runs unit tests"},
"tidy": {Fn: bdjuno.Tidy, Description: "Runs go mod tidy"},
}

0 comments on commit ed49d38

Please sign in to comment.