diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 0e37fd02..00000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,47 +0,0 @@ -on: [push, pull_request] -name: every commit -jobs: - - build: - runs-on: ubuntu-latest - name: build - steps: - - uses: actions/checkout@v3 - - name: Setup go - uses: actions/setup-go@v4 - with: - go-version: 1.20.0 - - run: go build ./... - - test: - runs-on: ubuntu-latest - name: test - steps: - - name: Install Go - uses: actions/setup-go@v4 - with: - go-version: 1.20.0 - - name: Checkout code - uses: actions/checkout@v3 - - name: Test - run: go test ./... - -# Use --check or --exit-code when available (Go 1.19?) -# https://github.com/golang/go/issues/27005 - tidy: - runs-on: ubuntu-latest - name: tidy - steps: - - uses: actions/checkout@v3 - - name: Setup go - uses: actions/setup-go@v4 - with: - go-version: 1.20.0 - - run: | - go mod tidy - CHANGES_IN_REPO=$(git status --porcelain) - if [[ -n "$CHANGES_IN_REPO" ]]; then - echo "Repository is dirty. Showing 'git status' and 'git --no-pager diff' for debugging now:" - git status && git --no-pager diff - exit 1 - fi diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index bdd28129..076346df 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,4 +1,4 @@ -name: docker-build +name: Docker Build on: pull_request: diff --git a/.github/workflows/gosec.yml b/.github/workflows/gosec.yml index d7be3dd6..770493a5 100644 --- a/.github/workflows/gosec.yml +++ b/.github/workflows/gosec.yml @@ -3,9 +3,11 @@ on: push: branches: - main + - release/* pull_request: branches: - main + - release/* jobs: tests: runs-on: ubuntu-latest @@ -14,14 +16,16 @@ jobs: steps: - name: Checkout Source uses: actions/checkout@v3 - - uses: technote-space/get-diff-action@v3 + + - uses: technote-space/get-diff-action@v6 with: - SUFFIX_FILTER: | - .go - .mod - .sum + PATTERNS: | + **.go + **.mod + **.sum + - name: Run Gosec Security Scanner uses: informalsystems/gosec@master with: args: ./... - if: "env.GIT_DIFF != ''" + if: env.GIT_DIFF diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 77356670..e32cba60 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -2,33 +2,37 @@ name: Lint # Lint runs golangci-lint over the entire Gaia repository # This workflow is run on every pull request and push to main # The `golangci` job will pass without running if no *.{go, mod, sum} files have been modified. + on: pull_request: push: branches: - main - - master - "release/*" + jobs: golangci: name: golangci-lint runs-on: ubuntu-latest steps: + - uses: actions/checkout@v3 + - name: Setup Go uses: actions/setup-go@v4 with: go-version: 1.20.0 - - uses: actions/checkout@v3 - - uses: technote-space/get-diff-action@v4 + + - uses: technote-space/get-diff-action@v6 with: PATTERNS: | **/**.go go.mod go.sum + - uses: golangci/golangci-lint-action@v3 with: # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. version: v1.51.2 args: --timeout 10m github-token: ${{ secrets.github_token }} - if: "env.GIT_DIFF != ''" + if: env.GIT_DIFF diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 37ff77a9..10508781 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,11 +1,11 @@ -name: Build & Test +name: Test + on: pull_request: - push: branches: - main - - master - - "release/*" + - release/* + jobs: cleanup-runs: runs-on: ubuntu-latest @@ -13,28 +13,32 @@ jobs: - uses: rokroskar/workflow-run-cleanup-action@master env: GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/main'" test-coverage-upload: runs-on: ubuntu-latest steps: + - uses: actions/checkout@v3 - uses: actions/setup-go@v4 with: go-version: 1.20.0 - - uses: actions/checkout@v3 - - uses: technote-space/get-diff-action@v4 + + - uses: technote-space/get-diff-action@v6 + id: get-diff with: PATTERNS: | **/**.go go.mod go.sum + - name: build run: | make build + - name: test & coverage report creation run: | go test ./... -mod=readonly -timeout 12m -race -coverprofile=coverage.txt -covermode=atomic -tags='ledger test_ledger_mock' - if: "env.GIT_DIFF != ''" + if: env.GIT_DIFF + - name: filter out DONTCOVER run: | excludelist="$(find ./ -type f -name '*.go' | xargs grep -l 'DONTCOVER')" @@ -44,12 +48,13 @@ jobs: echo "Excluding ${filename} from coverage report..." sed -i.bak "/$(echo $filename | sed 's/\//\\\//g')/d" coverage.txt done - if: "env.GIT_DIFF != ''" + if: env.GIT_DIFF + - uses: codecov/codecov-action@v1 with: file: ./coverage.txt # optional fail_ci_if_error: true - if: "env.GIT_DIFF != ''" + if: env.GIT_DIFF test-simulation: runs-on: ubuntu-latest diff --git a/Makefile b/Makefile index 5e403a7a..3bb40f4c 100644 --- a/Makefile +++ b/Makefile @@ -123,7 +123,7 @@ build/linux/amd64: GOOS=linux GOARCH=amd64 go build -mod=readonly $(BUILD_FLAGS) -o "$@/terrad" ./cmd/terrad build/linux/arm64: - GOOS=linux GOARCH=arm64 go build -mod=readonly $(BUILD_FLAGS) -o "$@/terrad"./cmd/terrad + GOOS=linux GOARCH=arm64 go build -mod=readonly $(BUILD_FLAGS) -o "$@/terrad" ./cmd/terrad build/darwin/amd64: GOOS=darwin GOARCH=amd64 go build -mod=readonly $(BUILD_FLAGS) -o "$@/terrad" ./cmd/terrad