pkg

module
v1.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 5, 2024 License: Apache-2.0

README

abcxyz Common Packages

"abcxyz Common Packages" is not an official Google product.

Kitchen Sink

abcxyz pkg provides a place for sharing common abcxyz packages across the abcxyz repos.

GitHub Actions

There are reusable workflows inside ./.github/workflows, which encapsulate common CI/CD logic to reduce repetition. For security, the reusable workflows are pinned to specific references using ratchet.

The reusable workflows use a default runner image of ubuntu-latest, since this works for most use cases. We do not recommend customizing the runner image unless you need additional performance. To customize the runner image, set the runs-on key as an input to the reusable workflow to a valid JSON string representing the GitHub runs-on configuration. Because GitHub Actions reusable workflows do not support complex input types, these values must be a valid JSON-encoded string.

# Example of using a different runner
uses: 'abcxyz/pkg/.github/workflows/workflow.yml@main'
with:
  runs-on: '"macos-latest"' # double quoting is required

# Example of using a self-hosted runner
uses: 'abcxyz/pkg/.github/workflows/workflow.yml@main'
with:
  runs-on: '["self-hosted", "ubuntu-22.04"]'

# Example of using a label
uses: 'abcxyz/pkg/.github/workflows/workflow.yml@main'
with:
  runs-on: '{"label": "4-core"}'
go-lint.yml

Use this workflow to perform basic Go linting checks:

on:
  push:
    branches:
      - 'main'
    paths:
      - '**.go'
  pull_request:
    branches:
      - 'main'
    paths:
      - '**.go'
  workflow_dispatch:

jobs:
  lint:
    uses: 'abcxyz/pkg/.github/workflows/go-lint.yml@main'

Linting is done via golangci-lint. If a .golangci.yml file exists at the root of the repository, it uses those linter settings. Otherwise, it uses a set of sane defaults.

go-test.yml

Use this workflow to perform basic Go tests:

on:
  push:
    branches:
      - 'main'
    paths:
      - '**.go'
  pull_request:
    branches:
      - 'main'
    paths:
      - '**.go'
  workflow_dispatch:

jobs:
  lint:
    uses: 'abcxyz/pkg/.github/workflows/go-test.yml@main'

Testing is done via the go test command with:

  • Test caching disabled
  • Test shuffling enabled
  • Race detector enabled
  • A 10 minute timeout
terraform-lint.yml

Use this workflow to perform basic Terraform linting checks:

on:
  push:
    branches:
      - 'main'
    paths:
      - '**.tf'
  pull_request:
    branches:
      - 'main'
    paths:
      - '**.tf'
  workflow_dispatch:

jobs:
  lint:
    uses: 'abcxyz/pkg/.github/workflows/terraform-lint.yml@main'
    with:
      terraform_version: '1.2'
      directory: './terraform'

If you have multiple Terraform configurations, repeat the stanza for each directory. Linting is done in two steps:

  1. Run terraform validate. This will fail if the Terraform is invalid.

  2. Run terraform fmt and check the git diff. This will will if the Terraform file is not formatted. On failure, the output will include the diff.

want-lgtm-all.yml

Use this workflow to require an approval from all requested reviewers:

on:
  pull_request:
    types:
      - 'opened'
      - 'edited'
      - 'reopened'
      - 'synchronize'
      - 'ready_for_review'
      - 'review_requested'
      - 'review_request_removed'
  pull_request_review:
    types:
      - 'submitted'
      - 'dismissed'
      - 'edited'

concurrency:
  group: '${{ github.workflow }}-${{ github.event_name }}-${{ github.head_ref || github.ref }}'
  cancel-in-progress: true

permissions:
  actions: 'write'
  pull-requests: 'read'

jobs:
  want-lgtm-all:
    uses: 'abcxyz/pkg/.github/workflows/want-lgtm-all.yml@main'

When creating a pull request, include the text want_lgtm=all in the body to require an approval from all requested reviewers.

Directories

Path Synopsis
Package buildinfo provides functions for setting build information for CLIs and programs.
Package buildinfo provides functions for setting build information for CLIs and programs.
Package cache implements an in-memory cache for arbitrary objects.
Package cache implements an in-memory cache for arbitrary objects.
Package cfgloader provides common functionality to load configs.
Package cfgloader provides common functionality to load configs.
Package cli defines an SDK for building performant and consistent CLIs.
Package cli defines an SDK for building performant and consistent CLIs.
cmd
Package gcpmetadata provides a metadata client for interacting with the Google Cloud metadata server.
Package gcpmetadata provides a metadata client for interacting with the Google Cloud metadata server.
Package gcputil exposes helpers for interacting with Google Cloud.
Package gcputil exposes helpers for interacting with Google Cloud.
Package githubauth provides interfaces and implementations for authenticating to GitHub.
Package githubauth provides interfaces and implementations for authenticating to GitHub.
Package healthcheck provides simple health check implementations.
Package healthcheck provides simple health check implementations.
internal
tools/terraformlinter
Package terraformlinter contains a linter implementation that verifies terraform files against our internal style guide and reports on all violations.
Package terraformlinter contains a linter implementation that verifies terraform files against our internal style guide and reports on all violations.
Package logging is an opinionated structured logging library based on log/slog.
Package logging is an opinionated structured logging library based on log/slog.
Package multicloser provides a convenient way to join multiple "close" functions together so they can be called together.
Package multicloser provides a convenient way to join multiple "close" functions together so they can be called together.
Package protoutil provides mechanisms for interacting with proto.
Package protoutil provides mechanisms for interacting with proto.
Package render exposes high-performance HTML and JSON rendering functionality.
Package render exposes high-performance HTML and JSON rendering functionality.
Package serving provides an extremely opinionated serving infrastructure, with support net/http.Server and google.golang.org/grpc.Server.
Package serving provides an extremely opinionated serving infrastructure, with support net/http.Server and google.golang.org/grpc.Server.
Package sets defines efficient operations for common set operations.
Package sets defines efficient operations for common set operations.
Package testutil contains common util functions to facilitate tests.
Package testutil contains common util functions to facilitate tests.
Package timeutil provides mechanisms for interacting with times and durations.
Package timeutil provides mechanisms for interacting with times and durations.
Package workerpool defines abstractions for parallelizing tasks.
Package workerpool defines abstractions for parallelizing tasks.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL