diff --git a/.github/actions/setup-go/action.yml b/.github/actions/setup-go/action.yml index 489f608d5..b9d287a22 100644 --- a/.github/actions/setup-go/action.yml +++ b/.github/actions/setup-go/action.yml @@ -4,6 +4,15 @@ inputs: go-version: description: "The version of Golang to set up" required: true + key-prefix: + description: "A prefix to use for the cache key, to separate cache entries from other workflows" + required: false + use-build-cache: + description: "Whether to use the build cache" + required: false + # Boolean values aren't supported in the workflow syntax, so we use a + # string. To not confuse the value with true/false, we use 'yes' and 'no'. + default: 'yes' runs: using: "composite" @@ -16,19 +25,42 @@ runs: git config --global core.autocrlf false - name: setup go ${{ inputs.go-version }} - uses: actions/setup-go@v3 + uses: actions/setup-go@v5 with: go-version: '${{ inputs.go-version }}' - - name: go cache - uses: actions/cache@v3 + - name: go module and build cache + if: ${{ inputs.use-build-cache == 'yes' }} + uses: actions/cache@v4 with: + # In order: + # * Module download cache + # * Build cache (Linux) + # * Build cache (Mac) + # * Build cache (Windows) path: | - /home/runner/go/pkg/mod - /home/runner/.cache/go-build - key: litd-${{ runner.os }}-go-${{ inputs.go-version }}-${{ github.job }}-${{ hashFiles('**/go.sum') }} + ~/go/pkg/mod + ~/.cache/go-build + ~/Library/Caches/go-build + ~\AppData\Local\go-build + key: ${{ runner.os }}-go-${{ inputs.go-version }}-${{ inputs.key-prefix }}-${{ github.job }}-${{ hashFiles('**/go.sum') }} restore-keys: | - litd-${{ runner.os }}-go-${{ inputs.go-version }}-${{ github.job }}-${{ hashFiles('**/go.sum') }} - litd-${{ runner.os }}-go-${{ inputs.go-version }}-${{ github.job }}- - litd-${{ runner.os }}-go-${{ inputs.go-version }}- - litd-${{ runner.os }}-go- + ${{ runner.os }}-go-${{ inputs.go-version }}-${{ inputs.key-prefix }}-${{ github.job }}- + ${{ runner.os }}-go-${{ inputs.go-version }}-${{ inputs.key-prefix }}- + + - name: go module cache + if: ${{ inputs.use-build-cache == 'no' }} + uses: actions/cache@v4 + with: + # Just the module download cache. + path: | + ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ inputs.go-version }}-${{ inputs.key-prefix }}-no-build-cache-${{ github.job }}-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go-${{ inputs.go-version }}-${{ inputs.key-prefix }}-no-build-cache-${{ github.job }}- + ${{ runner.os }}-go-${{ inputs.go-version }}-${{ inputs.key-prefix }}-no-build-cache- + + - name: set GOPATH + shell: bash + run: | + echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6a6e65035..9dd797002 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,6 +8,15 @@ on: branches: - "*" +concurrency: + # Cancel any previous workflows if they are from a PR or push. + group: ${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +defaults: + run: + shell: bash + env: # If you change this value, please change it in the following files as well: # /Dockerfile @@ -29,7 +38,7 @@ jobs: steps: - name: git checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 @@ -68,7 +77,7 @@ jobs: steps: - name: git checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 @@ -88,6 +97,40 @@ jobs: - name: build CLI binaries run: make go-install-cli + ######################## + # cross compilation + ######################## + cross-compile: + name: cross compilation + runs-on: ubuntu-latest + strategy: + fail-fast: true + matrix: + # Please keep this list in sync with make/release_flags.mk! + include: + - name: i386 + sys: linux-386 + - name: amd64 + sys: darwin-amd64 linux-amd64 windows-amd64 + - name: arm + sys: darwin-arm64 linux-armv6 linux-armv7 linux-arm64 + steps: + - name: cleanup space + run: rm -rf /opt/hostedtoolcache + + - name: git checkout + uses: actions/checkout@v4 + + - name: setup go ${{ env.GO_VERSION }} + uses: ./.github/actions/setup-go + with: + go-version: '${{ env.GO_VERSION }}' + key-prefix: cross-compile + use-build-cache: 'no' + + - name: build release for all architectures (skip app build) + run: make go-release sys="${{ matrix.sys }}" + ######################## # proto compile check ######################## @@ -96,7 +139,7 @@ jobs: runs-on: ubuntu-latest steps: - name: git checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 @@ -132,7 +175,7 @@ jobs: runs-on: ubuntu-latest steps: - name: git checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 @@ -160,7 +203,7 @@ jobs: runs-on: ubuntu-latest steps: - name: git checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 @@ -173,7 +216,7 @@ jobs: run: mkdir -p app/build; touch app/build/index.html - name: run check - run: make lint mod-check + run: make mod-check && make lint ######################## # unit tests @@ -190,7 +233,7 @@ jobs: - unit steps: - name: git checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 @@ -210,7 +253,7 @@ jobs: runs-on: ubuntu-latest steps: - name: git checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 @@ -253,7 +296,7 @@ jobs: if: '!contains(github.event.pull_request.labels.*.name, ''no-changelog'')' steps: - name: git checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: release notes check run: scripts/check-release-notes.sh diff --git a/accounts/store_kvdb.go b/accounts/store_kvdb.go index 355b41795..47a7c7ac4 100644 --- a/accounts/store_kvdb.go +++ b/accounts/store_kvdb.go @@ -232,8 +232,8 @@ func (s *BoltStore) IncreaseAccountBalance(_ context.Context, id AccountID, update := func(account *OffChainBalanceAccount) error { if amount > math.MaxInt64 { - return fmt.Errorf("amount %d exceeds the maximum of %d", - amount, math.MaxInt64) + return fmt.Errorf("amount %v exceeds the maximum of %v", + amount, int64(math.MaxInt64)) } account.CurrentBalance += int64(amount)