From 85dbfd8fb8a979c25908b7214c56e057677adad8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sindre=20R=C3=B8kenes=20Myren?= Date: Fri, 1 Oct 2021 09:10:36 +0200 Subject: [PATCH 1/2] Add GitHub Actions Back-ported from https://github.com/searis/rest-layer --- .github/workflows/go.yml | 141 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100644 .github/workflows/go.yml diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml new file mode 100644 index 0000000..5733b3f --- /dev/null +++ b/.github/workflows/go.yml @@ -0,0 +1,141 @@ +name: Test + +on: + pull_request: + branches: + - main + push: + branches: + - main + +jobs: + go: + runs-on: ubuntu-latest + strategy: + matrix: + go: ["1.17"] + path: ["", "examples"] + name: Go ${{ matrix.go }} ${{ matrix.path }} + steps: + - name: Setup go + uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.go }} + + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup Go modules cache + id: cache-go-module + uses: actions/cache@v2 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-gomod-${{ matrix.path }}-${{ hashFiles('go.sum') }}- + restore-keys: | + ${{ runner.os }}-gomod- + + - name: Setup Go build cache + id: cache-go-build + uses: actions/cache@v2 + with: + path: ~/.cache/go-build + key: ${{ runner.os }}-gobuild-${{ matrix.path }}-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-gobuild- + + - name: Download dependencies + working-directory: ${{ matrix.path }} + if: steps.cache-go-module.outputs.cache-hit != 'true' + run: go mod download + + - name: Verify go modules up to date + working-directory: ${{ matrix.path }} + run: | + set -ex + go mod tidy + [ -z "$(git diff -- go.{mod,sum})" ] # Check there are no changes! + + - name: Test + working-directory: ${{ matrix.path }} + run: go test ./... + + - name: Lint + uses: golangci/golangci-lint-action@v2 + with: + version: v1.41 + skip-go-installation: true + github-token: ${{ secrets.GITHUB_TOKEN }} + only-new-issues: false + skip-pkg-cache: true + skip-build-cache: true + args: --timeout=10m + working-directory: ${{ matrix.path }} + + go-mongo: + runs-on: ubuntu-latest + services: + mongo: + image: mongo:4.0 + ports: + - "27017" + strategy: + matrix: + go: ["1.17"] + path: ["storers/mongo"] + name: Go ${{ matrix.go }} ${{ matrix.path }} + steps: + - name: Setup go + uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.go }} + + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup Go modules cache + id: cache-go-module + uses: actions/cache@v2 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-gomod-${{ matrix.path }}-${{ hashFiles('go.sum') }}- + restore-keys: | + ${{ runner.os }}-gomod- + + - name: Setup Go build cache + id: cache-go-build + uses: actions/cache@v2 + with: + path: ~/.cache/go-build + key: ${{ runner.os }}-gobuild-${{ matrix.path }}-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-gobuild- + + - name: Download dependencies + working-directory: ${{ matrix.path }} + if: steps.cache-go-module.outputs.cache-hit != 'true' + run: go mod download + + - name: Verify go modules up to date + working-directory: ${{ matrix.path }} + run: | + set -ex + go mod tidy + [ -z "$(git diff -- go.{mod,sum})" ] # Check there are no changes! + + - name: Test + env: + GOTEST_MONGODB: mongodb://localhost:${{ job.services.mongo.ports[27017] }} + working-directory: ${{ matrix.path }} + run: go test ./... + + - name: Lint + uses: golangci/golangci-lint-action@v2 + with: + version: v1.41 + skip-go-installation: true + github-token: ${{ secrets.GITHUB_TOKEN }} + only-new-issues: false + skip-pkg-cache: true + skip-build-cache: true + args: --timeout=10m + working-directory: ${{ matrix.path }} From 51509c3590f9a612d2db723ab96cf9643dd71ec1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sindre=20R=C3=B8kenes=20Myren?= Date: Fri, 1 Oct 2021 09:21:47 +0200 Subject: [PATCH 2/2] Remove GitHub Actions mongodb test Remove test from back-ports for non-existent folder storers/mongo. --- .github/workflows/go.yml | 69 ---------------------------------------- 1 file changed, 69 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 5733b3f..38d33b3 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -70,72 +70,3 @@ jobs: skip-build-cache: true args: --timeout=10m working-directory: ${{ matrix.path }} - - go-mongo: - runs-on: ubuntu-latest - services: - mongo: - image: mongo:4.0 - ports: - - "27017" - strategy: - matrix: - go: ["1.17"] - path: ["storers/mongo"] - name: Go ${{ matrix.go }} ${{ matrix.path }} - steps: - - name: Setup go - uses: actions/setup-go@v2 - with: - go-version: ${{ matrix.go }} - - - name: Checkout - uses: actions/checkout@v2 - - - name: Setup Go modules cache - id: cache-go-module - uses: actions/cache@v2 - with: - path: ~/go/pkg/mod - key: ${{ runner.os }}-gomod-${{ matrix.path }}-${{ hashFiles('go.sum') }}- - restore-keys: | - ${{ runner.os }}-gomod- - - - name: Setup Go build cache - id: cache-go-build - uses: actions/cache@v2 - with: - path: ~/.cache/go-build - key: ${{ runner.os }}-gobuild-${{ matrix.path }}-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-gobuild- - - - name: Download dependencies - working-directory: ${{ matrix.path }} - if: steps.cache-go-module.outputs.cache-hit != 'true' - run: go mod download - - - name: Verify go modules up to date - working-directory: ${{ matrix.path }} - run: | - set -ex - go mod tidy - [ -z "$(git diff -- go.{mod,sum})" ] # Check there are no changes! - - - name: Test - env: - GOTEST_MONGODB: mongodb://localhost:${{ job.services.mongo.ports[27017] }} - working-directory: ${{ matrix.path }} - run: go test ./... - - - name: Lint - uses: golangci/golangci-lint-action@v2 - with: - version: v1.41 - skip-go-installation: true - github-token: ${{ secrets.GITHUB_TOKEN }} - only-new-issues: false - skip-pkg-cache: true - skip-build-cache: true - args: --timeout=10m - working-directory: ${{ matrix.path }}