diff --git a/.gitignore b/.gitignore index 7e874de..414c85f 100644 --- a/.gitignore +++ b/.gitignore @@ -65,3 +65,6 @@ typings/ # next.js build output .next + +# Local planning docs +docs/ diff --git a/README.md b/README.md index 1e3bf44..32ff894 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,41 @@ slack_always|No|If set, both success and failure notifications will be sent to S enable_ssh|No|If set, SSH sessions will be created on failure. ssh_always|No|If set, SSH sessions will always be created, even on success. +## Composite Actions + +This repo also contains reusable composite actions for CI/CD pipelines: + +### Go +| Action | Description | +|--------|-------------| +| `go/build` | Build Go repo, configure environment, install dependencies | +| `go/test` | Run Go tests with coverage and artifact upload | +| `go/lint` | Run golangci-lint with v1/v2 config auto-detection | +| `go/build-and-test` | Combined build + test with optional `TEST_SETUP_COMMANDS` and `CODE_GEN_COMMANDS` | +| `go/deps` | Install Go dependencies, vendor modules, generate mocks. Supports `CODE_GEN_COMMANDS` for pre-vendor code generation (sqlc, wire, ent) | +| `go/configure` | Configure Go environment (GOPRIVATE, buf, etc.) | +| `go/smoke-test` | Post-deploy smoke tests with optional DataDog Synthetics | + +### Ruby +| Action | Description | +|--------|-------------| +| `ruby/deps` | Install Ruby dependencies via Bundler | +| `ruby/lint` | Run RuboCop linter | +| `ruby/test` | Run RSpec tests with artifact upload | +| `ruby/one-for-all` | One-for-all Helm chart validation | +| `ruby/validation/topic` | Kafka topic validation | +| `ruby/validation/schema` | Schema validation | + +### Shared +| Action | Description | +|--------|-------------| +| `deploy/eks` | Deploy to EKS (staging/production) with Slack notifications | +| `slack` | Send Slack notifications on job failure/success | +| `cache` | Cache/restore workspace between jobs | +| `common/branch-info` | Extract branch name and short SHA for use in other steps | + +Each action's inputs are documented in its `action.yml` file. Use `@v0` to track the latest stable version. + ## Contributing Please make sure to run `npm run prepare` before committing your files! You should probably add this to `.git/hooks/pre-commit`. diff --git a/go/build-and-test/action.yml b/go/build-and-test/action.yml index 48c11cf..606f2d9 100644 --- a/go/build-and-test/action.yml +++ b/go/build-and-test/action.yml @@ -36,6 +36,22 @@ inputs: description: A timeout value in seconds. If tests take longer than this, they will fail. Not setting this value will fallback to go test's default of 10 minutes. required: false default: "" + TEST_SETUP_COMMANDS: + description: Shell commands to run between build and test steps (e.g. DB migrations, seed data, config generation) + required: false + default: "" + PARALLEL: + description: Whether to run tests in parallel. Defaults to true. + required: false + default: "true" + MOCKERY_INSTALL_VERSION: + description: The version of mockery to use + required: false + default: "" + CODE_GEN_COMMANDS: + description: Shell commands to run before go mod tidy (e.g. sqlc generate, wire, ent generate) + required: false + default: "" runs: using: "composite" @@ -49,6 +65,20 @@ runs: FLIPPCIRCLECIPULLER_REPO_TOKEN: ${{ inputs.FLIPPCIRCLECIPULLER_REPO_TOKEN }} BUF_BUILD_USER: ${{ inputs.BUF_BUILD_USER }} BUF_BUILD_API_TOKEN: ${{ inputs.BUF_BUILD_API_TOKEN }} + MOCKERY_INSTALL_VERSION: ${{ inputs.MOCKERY_INSTALL_VERSION }} + CODE_GEN_COMMANDS: ${{ inputs.CODE_GEN_COMMANDS }} + - name: Run test setup commands + if: ${{ inputs.TEST_SETUP_COMMANDS != '' }} + shell: bash + run: | + set -e + eval "$TEST_SETUP_COMMANDS" + env: + TEST_SETUP_COMMANDS: ${{ inputs.TEST_SETUP_COMMANDS }} + DB_HOST: ${{ inputs.DB_HOST }} + DB_USER: ${{ inputs.DB_USER }} + DB_PASSWORD: ${{ inputs.DB_PASSWORD }} + DB_PORT: ${{ inputs.DB_PORT }} - name: Run custom Go test action uses: wishabi/github-actions/go/test@v0 env: @@ -59,6 +89,7 @@ runs: with: TAGS: ${{ inputs.TEST_TAGS }} TIMEOUT: ${{ inputs.TIMEOUT }} + PARALLEL: ${{ inputs.PARALLEL }} - name: Notify slack channel on failure if: failure() && inputs.SLACK_CHANNEL_ID != '' && github.ref == 'refs/heads/main' uses: slackapi/slack-github-action@v1.27.1 diff --git a/go/build/action.yml b/go/build/action.yml index 4b8572c..26c5ec4 100644 --- a/go/build/action.yml +++ b/go/build/action.yml @@ -17,6 +17,14 @@ inputs: SLACK_BOT_TOKEN: description: The Slack bot token to pass the data to required: false + MOCKERY_INSTALL_VERSION: + description: The version of mockery to use + required: false + default: "" + CODE_GEN_COMMANDS: + description: Shell commands to run before go mod tidy (e.g. sqlc generate, wire, ent generate) + required: false + default: "" runs: using: "composite" @@ -36,6 +44,8 @@ runs: BUF_TOKEN: ${{ inputs.BUF_BUILD_API_TOKEN }} with: FLIPPCIRCLECIPULLER_REPO_TOKEN: ${{ inputs.FLIPPCIRCLECIPULLER_REPO_TOKEN }} + MOCKERY_INSTALL_VERSION: ${{ inputs.MOCKERY_INSTALL_VERSION }} + CODE_GEN_COMMANDS: ${{ inputs.CODE_GEN_COMMANDS }} - name: Write build summary if: always() shell: bash diff --git a/go/deps/action.yml b/go/deps/action.yml index 4aa01e4..10f9d61 100644 --- a/go/deps/action.yml +++ b/go/deps/action.yml @@ -13,6 +13,10 @@ inputs: description: The version of mockery to use required: false default: "" + CODE_GEN_COMMANDS: + description: Shell commands to run before go mod tidy (e.g. sqlc generate, wire, ent generate) + required: false + default: "" runs: using: 'composite' @@ -35,6 +39,14 @@ runs: echo "Go: $(go version)" if command -v buf &> /dev/null; then echo "Buf: $(buf --version)"; fi echo "::endgroup::" + - name: Run code generation commands + if: ${{ inputs.CODE_GEN_COMMANDS != '' }} + shell: bash + run: | + set -e + eval "$CODE_GEN_COMMANDS" + env: + CODE_GEN_COMMANDS: ${{ inputs.CODE_GEN_COMMANDS }} - name: Setting up private modules access if: steps.vendor-cache.outputs.cache-hit != 'true' shell: bash