pkg

module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2022 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 incapsulate common CI/CD logic to reduce repetition. For security, the reusable workflows are pinned to specific references using ratchet.

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'
    with:
      go_version: '1.19'

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'
    with:
      go_version: '1.19'

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.

Directories

Path Synopsis
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 grpcutil provides utilities for getting information from the grpc context.
Package grpcutil provides utilities for getting information from the grpc context.
Package jwtutil provides mechanisms for interacting with JWTs.
Package jwtutil provides mechanisms for interacting with JWTs.
Package logging sets up and configures standard logging.
Package logging sets up and configures standard logging.
Package mysqltest provides an ephemeral MySQL server for testing database integration.
Package mysqltest provides an ephemeral MySQL server for testing database integration.
Package testutil contains common util functions to facilitate tests.
Package testutil contains common util functions to facilitate tests.
Package worker defines abstractions for parallelizing tasks.
Package worker defines abstractions for parallelizing tasks.

Jump to

Keyboard shortcuts

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