Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: break mono-package into individual packages #1000

Merged
merged 30 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
c95bfa0
fix: add go.mod that is specific to config package
hspitzley-czi Feb 22, 2024
39aa574
split into independent go.mods
hspitzley-czi Feb 22, 2024
67e67ca
Merge branch 'main' into hspitzley/reusable_config_loader_mod
hspitzley-czi Feb 22, 2024
b7c2492
feat: break mono-package into individual packages
hspitzley-czi Feb 22, 2024
e3c15cc
fix some actions
hspitzley-czi Feb 22, 2024
4ac11b5
matrix go.mod update
hspitzley-czi Feb 22, 2024
94e5c0b
add 'needs'
hspitzley-czi Feb 22, 2024
480ceaa
set max-parallel: 1
hspitzley-czi Feb 22, 2024
3cb9d08
cancel in progress
hspitzley-czi Feb 22, 2024
d0dfaeb
remove max-parallel
hspitzley-czi Feb 22, 2024
e4e8f14
fix kmsauth
hspitzley-czi Feb 22, 2024
16b744a
fix
hspitzley-czi Feb 22, 2024
d14a76b
composite action
hspitzley-czi Feb 22, 2024
e4695dc
matrix expansion for ci.yml jobs
hspitzley-czi Feb 22, 2024
f57808c
add makefiles
hspitzley-czi Feb 22, 2024
3a7d60a
name & concurrency group for ci.yml
hspitzley-czi Feb 22, 2024
fbc5ee1
set working-dir for setup step
hspitzley-czi Feb 22, 2024
5e1b02b
fix path in makefiles
hspitzley-czi Feb 22, 2024
2c686de
update linting
hspitzley-czi Feb 22, 2024
8a91590
try with correct reviewdog path
hspitzley-czi Feb 22, 2024
12fba57
fix reviewdog path again
hspitzley-czi Feb 22, 2024
447872d
fix aws package
hspitzley-czi Feb 22, 2024
83a7cc3
ci - update kmsauth go.mod
hspitzley-czi Feb 22, 2024
fa43a12
review dog hasnt been running bc the trigger was push and it only run…
hspitzley-czi Feb 23, 2024
7bdce94
use reviewdog action
hspitzley-czi Feb 23, 2024
5455149
cleanup
hspitzley-czi Feb 23, 2024
18360aa
test empty
hspitzley-czi Feb 23, 2024
12e5ae0
test empty again
hspitzley-czi Feb 23, 2024
9be406e
cleanup test
hspitzley-czi Feb 23, 2024
abc8e81
conventional commits job
hspitzley-czi Feb 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading