Skip to content

Commit

Permalink
feat!: break mono-package into individual packages (#1000)
Browse files Browse the repository at this point in the history
  • Loading branch information
hspitzley-czi authored Feb 23, 2024
1 parent 405c91b commit 5151c5e
Show file tree
Hide file tree
Showing 109 changed files with 1,435 additions and 5,892 deletions.
32 changes: 32 additions & 0 deletions .github/actions/find-changed-packages/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Find Changed Go Packages
description: Finds the changed Go packages in a PR

outputs:
changedGoPackages:
description: 'The changed Go packages'
value: ${{ steps.changedGoPackages.outputs.changedGoPackages }}

runs:
using: composite
steps:
- uses: dorny/[email protected]
id: filter
with:
initial-fetch-depth: '1'
list-files: json
filters: |
changed:
- added|modified: '**'
- uses: actions/github-script@v6
id: changedGoPackages
with:
script: |
const path = require("path")
const fs = require("fs")
const changedFiles = ${{ steps.filter.outputs.changed_files }}
const changedDirs = changedFiles.map(f => path.dirname(f))
const changedGoPackages = changedDirs.filter(d => fs.existsSync(path.join(d, "go.mod")))
const uniqueChangedGoPackages = [...new Set(changedGoPackages)];
console.log(`Found the following changed Go packages: ${JSON.stringify(uniqueChangedGoPackages, null, 2)}\n OG: ${JSON.stringify(changedFiles, null, 2)} `)
core.setOutput("changedGoPackages", uniqueChangedGoPackages)
12 changes: 7 additions & 5 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
version: 2
updates:
- package-ecosystem: gomod
directory: "/"
schedule:
interval: weekly
open-pull-requests-limit: 10
- package-ecosystem: gomod
directory: "/"
schedule:
interval: weekly
open-pull-requests-limit: 10
commit-message:
prefix: "chore: "
7 changes: 4 additions & 3 deletions .github/workflows/aws-mocks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@ jobs:
upgrade-aws-mocks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version-file: go.mod
go-version-file: aws/go.mod
id: go
- run: |
make generate-mocks
go mod tidy
working-directory: aws
- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
with:
Expand Down
79 changes: 62 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,68 @@
on: push
on:
- pull_request

name: CI

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
run:
runs-on: ubuntu-latest
find-changed-packages:
runs-on: [ARM64, self-hosted, Linux]
outputs:
changedPackages: ${{ steps.changedGoPackages.outputs.changedGoPackages }}
steps:
- uses: actions/checkout@v4
- name: Find Changed Go Packages
id: changedGoPackages
uses: ./.github/actions/find-changed-packages

run-lint:
runs-on: [ARM64, self-hosted, Linux]
needs: find-changed-packages
if: ${{ needs.find-changed-packages.outputs.changedPackages != '[]' }}
strategy:
matrix:
gopkg: ${{ fromJson(needs.find-changed-packages.outputs.changedPackages) }}

steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: ${{ matrix.gopkg }}/go.mod
- name: Run golangci-lint
uses: reviewdog/action-golangci-lint@v2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
go_version_file: ${{ matrix.gopkg }}/go.mod
level: info
reporter: github-pr-review
golangci_lint_flags: "--config=../.golangci.yml --out-format=line-number -v --timeout 5m"
workdir: ${{ matrix.gopkg }}

run-tests:
runs-on: [ARM64, self-hosted, Linux]
needs: find-changed-packages
if: ${{ needs.find-changed-packages.outputs.changedPackages != '[]' }}
strategy:
matrix:
target:
- check-mod
- lint-ci
- test-ci
gopkg: ${{ fromJson(needs.find-changed-packages.outputs.changedPackages) }}

steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Install dependencies
run: make setup

- name: make ${{ matrix.target }}
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: make ${{ matrix.target }}
go-version-file: ${{ matrix.gopkg }}/go.mod
- name: Run tests
run: make test-ci
working-directory: ${{ matrix.gopkg }}

# this job exists to give us something to make a required check on that will ensure all CI runs are complete
run-ci-complete:
runs-on: [ARM64, self-hosted, Linux]
needs:
- run-tests
- run-lint
steps:
- run: echo "CI runs complete"
19 changes: 19 additions & 0 deletions .github/workflows/conventional-commits.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Validates PR title follows conventional commits
name: conventional-commits
on:
pull_request:
branches: main
types:
- edited
- opened
- synchronize
- reopened

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
conventional_commit_title:
runs-on: [ARM64, self-hosted, Linux]
steps:
- uses: chanzuckerberg/github-actions/.github/actions/[email protected]
32 changes: 0 additions & 32 deletions .github/workflows/mod-update.yaml

This file was deleted.

59 changes: 59 additions & 0 deletions .github/workflows/mod-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
on:
- pull_request

name: Update go.mod

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
find-changed-packages:
runs-on: [ARM64, self-hosted, Linux]
outputs:
changedPackages: ${{ steps.changedGoPackages.outputs.changedGoPackages }}
steps:
- uses: actions/checkout@v4
- name: Find Changed Go Packages
id: changedGoPackages
uses: ./.github/actions/find-changed-packages

update-go-mod:
runs-on: [ARM64, self-hosted, Linux]
needs: find-changed-packages
strategy:
matrix:
gopkg: ${{ fromJson(needs.find-changed-packages.outputs.changedPackages) }}
if: ${{ needs.find-changed-packages.outputs.changedPackages != '[]' }}
outputs:
updated_go_mod: ${{ steps.commit_go_mod.outputs.committed }}
steps:
- name: Generate token
id: generate_token
uses: chanzuckerberg/[email protected]
with:
app_id: ${{ secrets.CZI_GITHUB_HELPER_APP_ID }}
private_key: ${{ secrets.CZI_GITHUB_HELPER_PK }}
- uses: actions/checkout@v4
with:
token: ${{ steps.generate_token.outputs.token }}
ref: ${{ github.event.pull_request.head.ref }}
- uses: actions/setup-go@v5
with:
go-version-file: ${{ matrix.gopkg }}/go.mod
cache: true
- name: Update go.mod
run: go mod tidy
working-directory: ${{ matrix.gopkg }}
- uses: EndBug/add-and-commit@v9
id: commit_go_mod
with:
add: -A
message: ci - update ${{ matrix.gopkg }}/go.mod

# this job exists to give us something to make a required check on that will ensure all go.mod updates are complete
go-mod-updates-complete:
runs-on: [ARM64, self-hosted, Linux]
needs: update-go-mod
steps:
- run: echo "Go mod updates complete"
60 changes: 38 additions & 22 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,44 @@
linters:
enable:
- asciicheck
- bodyclose
- deadcode
- dupl
- depguard
- errcheck
- exportloopref
- goconst
- gocyclo
- errorlint
- forbidigo
- gci
- gofmt
- goimports
- golint
- gosec
- interfacer
- megacheck
- misspell
- nlreturn
- nolintlint
- rowserrcheck
- scopelint
- sqlclosecheck
- structcheck
- unconvert
- unparam
- varcheck
- gosimple
- govet
- ineffassign
- staticcheck
- typecheck
- unused
- whitespace
- wsl

linters-settings:
forbidigo:
# These are forbidden in non-test files
# If you have mock functions,etc that are meant to be used in tests please add them here
forbid:
- ^fmt\.Print.*$
- ^spew\.Dump$
- ^println$
depguard:
rules:
main:
deny:
- pkg: gopkg.in/yaml.v2
desc: please use gopkg.in/yaml.v3 instead
- pkg: github.com/pkg/errors
desc: please use errors from the standard library instead
- pkg: golang.org/x/xerrors
desc: please use errors from the standard library instead
- pkg: github.com/sirupsen/logrus
desc: please use log/slog from the standard library instead

issues:
exclude-rules:
# Exclude some linters from running on tests files.
- path: _test\.go
linters:
- forbidigo
17 changes: 16 additions & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1 +1,16 @@
{".":"1.12.0"}
{
".": "1.12.0",
"aws": "1.12.0",
"config": "1.12.0",
"errors": "1.12.0",
"keypair": "1.12.0",
"kmsauth": "1.12.0",
"oidc_cli": "1.12.0",
"osutil": "1.12.0",
"pidlock": "1.12.0",
"sets": "1.12.0",
"slack": "1.12.0",
"snowflake": "1.12.0",
"survey": "1.12.0",
"ver": "1.12.0"
}
8 changes: 0 additions & 8 deletions .reviewdog.yml

This file was deleted.

11 changes: 11 additions & 0 deletions aws/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

include ../scripts/common.mk

generate-mocks: ## will generate mocks
go install github.com/golang/mock/[email protected]
go get -u github.com/aws/aws-sdk-go/...
go get -u github.com/aws/aws-sdk-go-v2/...
rm -rf aws/mocks/*
cd aws; go generate
go mod tidy
.PHONY: generate-mocks
18 changes: 18 additions & 0 deletions aws/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module github.com/chanzuckerberg/go-misc/aws

go 1.21

toolchain go1.21.1

require (
github.com/aws/aws-sdk-go v1.50.23
github.com/golang/mock v1.6.0
github.com/pkg/errors v0.9.1
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
golang.org/x/net v0.21.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)
Loading

0 comments on commit 5151c5e

Please sign in to comment.