Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI workflow #65

Merged
merged 6 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"},
}