diff --git a/.github/composites/setup-defradb/action.yml b/.github/composites/setup-defradb/action.yml new file mode 100644 index 0000000000..1308c59b6c --- /dev/null +++ b/.github/composites/setup-defradb/action.yml @@ -0,0 +1,76 @@ +# Copyright 2024 Democratized Data Foundation +# +# Use of this software is governed by the Business Source License +# included in the file licenses/BSL.txt. +# +# As of the Change Date specified in that file, in accordance with +# the Business Source License, use of this software will be governed +# by the Apache License, Version 2.0, included in the file +# licenses/APL.txt. + +name: 'Setup DefraDB Composite' + +description: 'Reusable composite action to setup defradb' + +runs: + # This is a composite action, setting this is required. + using: "composite" + + # For a composite action, it's required for every step to specify shell. + steps: + - name: Setup Go environment explicitly + uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + check-latest: true + cache: false + shell: bash + + - name: Set cache paths + id: cache-paths + run: | + echo "GO_CACHE=$(go env GOCACHE)" >> "${GITHUB_OUTPUT}" + echo "GO_MODCACHE=$(go env GOMODCACHE)" >> "${GITHUB_OUTPUT}" + echo "CARGO_CACHE=~/.cargo" >> "${GITHUB_OUTPUT}" + shell: bash + + - name: Go cache/restore + uses: actions/cache@v4 + with: + key: ${{ runner.os }}-go-${{ hashFiles('**/go.mod') }} + path: | + ${{ steps.cache-paths.outputs.GO_CACHE }} + ${{ steps.cache-paths.outputs.GO_MODCACHE }} + shell: bash + + - name: Cargo cache/restore + # A very cool post: https://blog.arriven.wtf/posts/rust-ci-cache + uses: actions/cache@v4 + with: + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }} + # Here are some directories we shouldn't forget about: + # ~/.cargo/.* + # ~/.cargo/bin/ + # ~/.cargo/git/db/ + # ~/.cargo/registry/cache/ + # ~/.cargo/registry/index/ + # **/target/*/*.d + # **/target/*/*.rlib + # **/target/*/.fingerprint + # **/target/*/build + # **/target/*/deps + path: | + ${{ steps.cache-paths.outputs.CARGO_CACHE }} + **/target/ + shell: bash + + - name: Restore modified time + uses: chetan/git-restore-mtime-action@v2 + shell: bash + + - name: Build dependencies + run: | + make deps:modules + make deps:test + shell: bash + diff --git a/.github/workflows/test-and-upload-coverage.yml b/.github/workflows/test-and-upload-coverage.yml index 29c6b2fd10..41821e86f0 100644 --- a/.github/workflows/test-and-upload-coverage.yml +++ b/.github/workflows/test-and-upload-coverage.yml @@ -1,4 +1,4 @@ -# Copyright 2022 Democratized Data Foundation +# Copyright 2024 Democratized Data Foundation # # Use of this software is governed by the Business Source License # included in the file licenses/BSL.txt. @@ -79,56 +79,8 @@ jobs: - name: Checkout code into the directory uses: actions/checkout@v4 - - name: Setup Go environment explicitly - uses: actions/setup-go@v5 - with: - go-version-file: 'go.mod' - check-latest: true - cache: false - - - name: Set cache paths - id: cache-paths - shell: bash - run: | - echo "GO_CACHE=$(go env GOCACHE)" >> "${GITHUB_OUTPUT}" - echo "GO_MODCACHE=$(go env GOMODCACHE)" >> "${GITHUB_OUTPUT}" - echo "CARGO_CACHE=~/.cargo" >> "${GITHUB_OUTPUT}" - - - name: Go cache/restore - uses: actions/cache@v4 - with: - key: ${{ runner.os }}-go-${{ hashFiles('**/go.mod') }} - path: | - ${{ steps.cache-paths.outputs.GO_CACHE }} - ${{ steps.cache-paths.outputs.GO_MODCACHE }} - - - name: Cargo cache/restore - # A very cool post: https://blog.arriven.wtf/posts/rust-ci-cache - uses: actions/cache@v4 - with: - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }} - # Here are some directories we shouldn't forget about: - # ~/.cargo/.* - # ~/.cargo/bin/ - # ~/.cargo/git/db/ - # ~/.cargo/registry/cache/ - # ~/.cargo/registry/index/ - # **/target/*/*.d - # **/target/*/*.rlib - # **/target/*/.fingerprint - # **/target/*/build - # **/target/*/deps - path: | - ${{ steps.cache-paths.outputs.CARGO_CACHE }} - **/target/ - - - name: Restore modified time - uses: chetan/git-restore-mtime-action@v2 - - - name: Build dependencies - run: | - make deps:modules - make deps:test + - name: Setup defradb + uses: ./.github/composites/setup-defradb - name: Run integration tests run: make test:coverage @@ -169,44 +121,8 @@ jobs: - name: Checkout code into the directory uses: actions/checkout@v4 - - name: Setup Go environment explicitly - uses: actions/setup-go@v5 - with: - go-version-file: 'go.mod' - check-latest: true - cache: false - - - name: Set cache paths - id: cache-paths - shell: bash - run: | - echo "GO_CACHE=$(go env GOCACHE)" >> "${GITHUB_OUTPUT}" - echo "GO_MODCACHE=$(go env GOMODCACHE)" >> "${GITHUB_OUTPUT}" - echo "CARGO_CACHE=~/.cargo" >> "${GITHUB_OUTPUT}" - - - name: Go cache/restore - uses: actions/cache@v4 - with: - key: ${{ runner.os }}-go-${{ hashFiles('**/go.mod') }} - path: | - ${{ steps.cache-paths.outputs.GO_CACHE }} - ${{ steps.cache-paths.outputs.GO_MODCACHE }} - - - name: Cargo cache/restore - uses: actions/cache@v4 - with: - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }} - path: | - ${{ steps.cache-paths.outputs.CARGO_CACHE }} - **/target/ - - - name: Restore modified time - uses: chetan/git-restore-mtime-action@v2 - - - name: Build dependencies - run: | - make deps:modules - make deps:test + - name: Setup defradb + uses: ./.github/composites/setup-defradb # We have to checkout the source-hub repo and install it ourselves because it # contains replace commands in its go.mod file.