diff --git a/.github/workflows/go.yaml b/.github/workflows/go.yaml index ce7845d..39624e6 100644 --- a/.github/workflows/go.yaml +++ b/.github/workflows/go.yaml @@ -10,26 +10,23 @@ jobs: name: 📦 Build & Test runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - - name: Set up Go - uses: actions/setup-go@v2 + - uses: actions/checkout@v3 + - uses: docker/setup-buildx-action@v2 + - uses: docker/login-action@v2 with: - go-version: '1.21' - - - name: Build - run: go build - - - name: Test - run: go test -coverpkg='./internal/...' -v './...' - - - name: Vet - run: go vet ./... - - - name: Run coverage - run: go test -coverpkg='./internal/...' -coverprofile=coverage.out -covermode=atomic ./... - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v3 + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - id: meta + uses: docker/metadata-action@v5 + images: ghcr.io/${{ github.repository }} + tags: | + type=ref,event=branch,pattern=snapshot-{{sha}} + - uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} release: name: 🚀 Release @@ -38,25 +35,22 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: actions/setup-go@v3 + - uses: docker/login-action@v2 with: - go-version: '1.21' - - run: go build + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - uses: go-semantic-release/action@v1 with: hooks: goreleaser prerelease: false allow-initial-development-versions: true # remove to trigger an initial 1.0.0 release changelog-generator-opt: "emojis=true" - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} -# - name: Login to Docker Hub -# uses: docker/login-action@v2 -# with: -# username: ${{ secrets.DOCKERHUB_USERNAME }} -# password: ${{ secrets.DOCKERHUB_TOKEN }} -# - name: Docker Hub Description -# uses: peter-evans/dockerhub-description@v3 -# with: -# username: ${{ secrets.DOCKERHUB_USERNAME }} -# password: ${{ secrets.DOCKERHUB_PASSWORD }} + github-token: ${{ secrets.GITHUB_TOKEN }} + - run: | + TAG=${{ steps.semantic-release.outputs.version }} + IMAGE=${{ needs.build.outputs.image }} + + docker pull $IMAGE + docker tag $IMAGE ghcr.io/${{ github.repository }}:$TAG + docker push ghcr.io/${{ github.repository }}:${{ steps.semantic-release.outputs.version }} diff --git a/Dockerfile b/Dockerfile index 9f46a40..16a4f76 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,6 @@ ARG GOLANG_VERSION=1-buster -ARG PACT_VERSION=1.88.63 FROM golang:${GOLANG_VERSION} as build -ARG PACT_VERSION - -# Install pact contract testing standalone binaries (includes Ruby) -RUN curl -LO https://github.com/pact-foundation/pact-ruby-standalone/releases/download/v${PACT_VERSION}/pact-${PACT_VERSION}-linux-x86_64.tar.gz; \ - tar -C /usr/local -xzf pact-${PACT_VERSION}-linux-x86_64.tar.gz; \ - rm pact-${PACT_VERSION}-linux-x86_64.tar.gz; \ - mkdir -p /app - -ENV PATH /usr/local/pact/bin:$PATH COPY . /app WORKDIR /app @@ -27,4 +17,4 @@ COPY --from=build /app/main /main COPY --from=build /etc/ssl/certs /etc/ssl/certs COPY --from=build /app/api/openapi-v3-spec.yaml /api/openapi-v3-spec.yaml -ENTRYPOINT ["/main"] \ No newline at end of file +ENTRYPOINT ["/main"] diff --git a/README.md b/README.md index ee20d69..207f509 100644 --- a/README.md +++ b/README.md @@ -270,16 +270,6 @@ Clone this outside your GOPATH (on linux, defaults to ~/go) _Tip: On Windows, you should NOT place the GOPATH in your profile, because a large body of source code goes there._ -### contract test setup - -This service uses [pact-go](https://github.com/pact-foundation/pact-go) for consumer driven contract tests. -We only interact with the vault api, so we are a _consumer_, and there is no pact-aware implementation -for the _producer_ side, instead this repository just comes with the relevant recordings, -which were manually created. - -Download and install the pact command line tools and add them to your path as described in the -[pact-go manual](https://github.com/pact-foundation/pact-go#installation). - ### generate api model classes **The generated models are checked in, so you only need to run this step if there is a change in the openapi specs.** @@ -296,7 +286,7 @@ In a git bash (or on Linux), run `./api-generator/generate.sh`. We have _given-when-then_ style acceptance tests. -Run all tests, including the acceptance and contract tests (will need to have pact installed): +Run all tests, including the acceptance: `go test -coverpkg='./internal/...' -v './...'`