Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
John Stableford committed Jan 13, 2024
1 parent c9a1494 commit fba8667
Show file tree
Hide file tree
Showing 76 changed files with 7,809 additions and 2,344 deletions.
File renamed without changes.
13 changes: 9 additions & 4 deletions .github/workflows/_build-and-verify.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ jobs:
- name: Setup
uses: ./.github/actions/setup
with:
go-enabled: true
java-enabled: true
app-deps-enabled: true
go-enabled: false
java-enabled: false
app-deps-enabled: false
tool-deps-enabled: true

verify:
Expand Down Expand Up @@ -112,6 +112,9 @@ jobs:
runs-on: ubuntu-latest
needs:
- cache-setup
env:
# TODO: use podman compose https://github.com/redhat-actions/buildah-build/issues/116#issuecomment-1890340223
DEVSTACK_COMPOSE_TOOL: docker-compose
steps:
- name: Checkout repository
uses: actions/checkout@v3
Expand All @@ -133,10 +136,12 @@ jobs:
- name: Run integration tests
shell: bash
run: |
make test.integration
make test.integration.report
- name: Capture coverage reports
shell: bash
env:
TEST_SUITE: test.integration
run: |
make devstack.capture-coverage-reports
Expand Down
54 changes: 22 additions & 32 deletions .github/workflows/_package-and-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ on:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
package-and-publish:
name: 'Package and publish'
runs-on: ubuntu-latest
strategy:
matrix:
image: [frontdoor, worker, mocks]
permissions:
contents: read
packages: write
Expand All @@ -25,52 +27,40 @@ jobs:
uses: actions/checkout@v3

- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
uses: redhat-actions/podman-login@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for frontdoor
id: service-frontdoor-meta
- name: Extract metadata (tags, labels) for ${{matrix.image}}
id: service-meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ inputs.registry }}/${{ github.repository }}/service-frontdoor
images: ${{ inputs.registry }}/${{ github.repository }}/service-${{matrix.image}}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=latest,enable={{is_default_branch}}
- name: Extract metadata (tags, labels) for worker
id: service-worker-meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ inputs.registry }}/${{ github.repository }}/service-worker
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push frontdoor image
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
- name: Build ${{matrix.image}} image
id: build-image
uses: redhat-actions/buildah-build@v2
with:
context: .
push: true
tags: ${{ steps.service-frontdoor-meta.outputs.tags }}
labels: ${{ steps.service-frontdoor-meta.outputs.labels }}
tags: ${{ steps.service-meta.outputs.tags }}
labels: ${{ steps.service-meta.outputs.labels }}
containerfiles: |
./Containerfile.alt
build-args: |
entrypoint=modules/frontdoor/cmd/frontdoor
entrypoint=modules/${{matrix.image}}/cmd/${{matrix.image}}
extra-args: |
--target runtime
- name: Build and push worker image
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
- name: Push ${{matrix.image}} image
id: push-image
uses: redhat-actions/push-to-registry@v2
with:
context: .
push: true
tags: ${{ steps.service-worker-meta.outputs.tags }}
labels: ${{ steps.service-worker-meta.outputs.labels }}
build-args: |
entrypoint=modules/worker/cmd/worker
image: ${{ steps.build-image.outputs.image }}
tags: ${{ steps.build-image.outputs.tags }}
31 changes: 6 additions & 25 deletions .github/workflows/feature-branch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,13 @@ jobs:
needs:
- workflow-variables

release-dryrun-dev:
name: dryrun-dev
release-dryrun-qa:
name: dryrun-qa
uses: ./.github/workflows/_release-dryrun.yaml
needs:
- workflow-variables
with:
env: dev

release-dryrun-test:
name: dryrun-test
uses: ./.github/workflows/_release-dryrun.yaml
needs:
- workflow-variables
with:
env: test
env: qa

release-dryrun-prod:
name: dryrun-prod
Expand All @@ -67,23 +59,12 @@ jobs:
with:
env: prod

release-dev:
name: release-dev
uses: ./.github/workflows/_release.yaml
needs:
- workflow-variables
- package-and-publish
with:
env: dev
smoke-tests-enabled: true

release-test:
name: release-test
release-qa:
name: release-qa
uses: ./.github/workflows/_release.yaml
needs:
- workflow-variables
- package-and-publish
- release-dev
with:
env: test
env: qa
smoke-tests-enabled: true
18 changes: 4 additions & 14 deletions .github/workflows/main-branch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,33 +41,23 @@ jobs:
needs:
- workflow-variables

release-dev:
name: release-dev
release-qa:
name: release-qa
uses: ./.github/workflows/_release.yaml
needs:
- workflow-variables
- build-and-verify
- package-and-publish
with:
env: dev
smoke-tests-enabled: true

release-test:
name: release-test
uses: ./.github/workflows/_release.yaml
needs:
- workflow-variables
- release-dev
with:
env: test
env: qa
smoke-tests-enabled: true

release-prod:
name: release-prod
uses: ./.github/workflows/_release.yaml
needs:
- workflow-variables
- release-test
- release-qa
with:
env: prod
smoke-tests-enabled: false
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@ __debug_bin*
/*.session.sql

/reports/**

# Test artifacts
/test-harness/suites/**/ginkgo.report
2 changes: 2 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ linters-settings:
desc: not allowed, use slog
- pkg: "go.uber.org/zap"
desc: not allowed, use slog
- pkg: "istio.io/pkg/log"
desc: not allowed, use slog
error_rules:
deny:
- pkg: "github.com/go-errors/errors"
Expand Down
26 changes: 26 additions & 0 deletions .mockery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ with-expecter: true
inpackage: true
dir: "{{.InterfaceDir}}"
outpkg: "{{.PackageName}}"
replace-type:
- go.temporal.io/sdk/internal.StartWorkflowOptions=sdkclient:go.temporal.io/sdk/client.StartWorkflowOptions
- go.temporal.io/sdk/internal.WorkflowRun=sdkclient:go.temporal.io/sdk/client.WorkflowRun
- go.temporal.io/sdk/internal.Context=workflow:go.temporal.io/sdk/workflow.Context
packages:
github.com/pseudo-su/golang-temporal-service-template/modules/worker/pkg/workflowclient:
interfaces:
Expand All @@ -18,6 +22,28 @@ packages:
mockname: MockTemporalEncodedValue
filename: mock_TemporalEncodedValue.go

go.temporal.io/sdk/internal:
config:
dir: "modules/testing-tools/vendormocks"
interfaces:
WorkflowRun:
config:
inpackage: false
outpkg: "vendormocks"
mockname: MockTemporalWorkflowRun
filename: mock_TemporalWorkflowRun.go

go.temporal.io/sdk/client:
config:
dir: "modules/testing-tools/vendormocks"
interfaces:
Client:
config:
inpackage: false
outpkg: "vendormocks"
mockname: MockTemporalClient
filename: mock_TemporalClient.go

google.golang.org/grpc/health/grpc_health_v1:
config:
dir: "modules/testing-tools/vendormocks"
Expand Down
1 change: 1 addition & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// https://go.microsoft.com/fwlink/?LinkId=827846
"recommendations": [
"golang.go",
"joselitofilho.ginkgotestexplorer",
"mikestead.dotenv",
"mechatroner.rainbow-csv",
"editorconfig.editorconfig",
Expand Down
33 changes: 11 additions & 22 deletions Dockerfile → Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,50 +14,39 @@ RUN env GOBIN=/builddir go install github.com/grpc-ecosystem/grpc-health-probe@l

# Copy across
COPY go.work go.work.sum ./
COPY modules/worker/go.mod modules/worker/go.sum ./modules/worker/
COPY modules/frontdoor/go.mod modules/frontdoor/go.sum ./modules/frontdoor/
COPY modules/mocks/go.mod modules/mocks/go.sum ./modules/mocks/
COPY modules/service-cli/go.mod modules/service-cli/go.sum ./modules/service-cli/
COPY modules/service-pkg/go.mod modules/service-pkg/go.sum ./modules/service-pkg/
COPY modules/testing-tools/go.mod modules/testing-tools/go.sum ./modules/testing-tools/
COPY modules/worker/go.mod modules/worker/go.sum ./modules/worker/
COPY test-harness/go.mod test-harness/go.sum ./test-harness/

# Install go application dependencies
RUN --mount=type=cache,target=/go/pkg/mod/ \
go mod download -x

FROM builder-base AS builder-instrumented
FROM builder-base AS builder

ARG entrypoint
ARG gobuildopts=

ADD . .
RUN --mount=type=cache,target=/go/pkg/mod/ \
--mount=type=cache,target=/root/.cache/go-build \
--mount=type=bind,target=. \
CGO_ENABLED=0 go build -cover -v -o /builddir/service ./$entrypoint
CGO_ENABLED=0 go build ${gobuildopts} -v -o /builddir/service ./$entrypoint

FROM builder-base as builder

ARG entrypoint

RUN --mount=type=cache,target=/go/pkg/mod/ \
--mount=type=cache,target=/root/.cache/go-build \
--mount=type=bind,target=. \
CGO_ENABLED=0 go build -v -o /builddir/service ./$entrypoint
FROM gcr.io/distroless/static AS runtime-base

FROM gcr.io/distroless/static as runtime-base
USER nonroot

COPY --from=builder-base /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=builder-base /builddir/grpc-health-probe /bin

# non root
USER 65532

FROM runtime-base as runtime-instrumented

COPY --from=builder-instrumented /builddir/service /bin

ENTRYPOINT ["/bin/service"]

FROM runtime-base AS runtime

USER nonroot

COPY --from=builder /builddir/service /bin

ENTRYPOINT ["/bin/service"]

0 comments on commit fba8667

Please sign in to comment.