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: test packages separately #150

Merged
merged 33 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
6e51784
feat: test packages separately
trevorwhitney Apr 17, 2024
845b218
fix: put package name in job name
trevorwhitney Apr 17, 2024
38fae5d
fix: checkout before gathering packages
trevorwhitney Apr 17, 2024
3e59444
fix: collect packages job
trevorwhitney Apr 17, 2024
fbbc071
fix: packages output/input references
trevorwhitney Apr 17, 2024
ca43fc9
fix: gotestsum command
trevorwhitney Apr 17, 2024
f886093
fix gotestsum command
trevorwhitney Apr 18, 2024
0824759
add dummy step to dummy test job
trevorwhitney Apr 18, 2024
b0adf92
fix gotestsum command again
trevorwhitney Apr 18, 2024
7d83803
where are the files
trevorwhitney Apr 18, 2024
c9eff48
throwing stuff at the wall
trevorwhitney Apr 18, 2024
abcbc13
will it blend?
trevorwhitney Apr 18, 2024
9a8aec9
now will it blend?
trevorwhitney Apr 18, 2024
a84778e
ignore push package
trevorwhitney Apr 18, 2024
573cf6c
parallelize more
trevorwhitney Apr 19, 2024
3fd35b5
fix golangcilint action version
trevorwhitney Apr 19, 2024
7e16e50
limit to directories with tests
trevorwhitney Apr 19, 2024
cc83f6a
try to fix golangcilint again
trevorwhitney Apr 19, 2024
a35d244
fix tool testing
trevorwhitney Apr 19, 2024
93ffd7c
revert all golangci-lint changes
trevorwhitney Apr 19, 2024
c9335fa
fix dummy collector steps
trevorwhitney Apr 19, 2024
dc1561a
break faillint into own file
trevorwhitney Apr 19, 2024
8fe7a94
simplify package collection logic
trevorwhitney Apr 19, 2024
375d3ba
ignore operator packages
trevorwhitney Apr 19, 2024
b6e71c2
test lambda-promtail seperately
trevorwhitney Apr 19, 2024
4a89905
clean up
trevorwhitney Apr 19, 2024
4b5e145
mimic pkg/push and lambda-promtail folder structure
trevorwhitney Apr 19, 2024
841b06f
add more test mimicing
trevorwhitney Apr 19, 2024
167050c
allow testify
trevorwhitney Apr 19, 2024
c45b5e0
allow testing import
trevorwhitney Apr 19, 2024
3abdf78
only need 1 dummy gate
trevorwhitney Apr 19, 2024
2d311c5
gate doesn't need to run in container
trevorwhitney Apr 19, 2024
74e4c07
fix gate job again
trevorwhitney Apr 19, 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
154 changes: 121 additions & 33 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,26 @@
"USE_GITHUB_APP_TOKEN": "${{ inputs.use_github_app_token }}"
"jobs":
"check":
"env":
"SKIP_VALIDATION": "${{ inputs.skip_validation }}"
"needs":
- "checkFiles"
- "faillint"
- "golangciLint"
- "lintFiles"
- "integration"
- "testLambdaPromtail"
- "testPackages"
- "testPushPackage"
"runs-on": "ubuntu-latest"
"steps":
- "name": "checkout"
"uses": "actions/checkout@v4"
- "if": "${{ !fromJSON(env.SKIP_VALIDATION) }}"
"name": "checks passed"
"run": |
echo "All checks passed"
"checkFiles":
"container":
"image": "${{ inputs.build_image }}"
"env":
Expand Down Expand Up @@ -78,7 +98,44 @@
cp -r docs/sources/* /hugo/content/docs/loki/latest/
cd /hugo && make prod
EOF
"integration":
"collectPackages":
"outputs":
"packages": "${{ steps.gather-tests.outputs.packages }}"
"runs-on": "ubuntu-latest"
"steps":
- "name": "checkout"
"uses": "actions/checkout@v4"
- "name": "fix git dubious ownership"
"run": |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
- "id": "gather-tests"
"name": "gather packages"
"run": |
echo "packages=$(find . -path '*_test.go' -printf '%h\n' \
| grep -e "pkg/push" -e "integration" -e "operator" -e "lambda-promtail" -v \
| cut -d / -f 2,3 \
| uniq \
| sort \
| jq --raw-input --slurp --compact-output 'split("\n")[:-1]')" >> ${GITHUB_OUTPUT}
"faillint":
"container":
"image": "${{ inputs.build_image }}"
"env":
"BUILD_IN_CONTAINER": false
"SKIP_VALIDATION": "${{ inputs.skip_validation }}"
"runs-on": "ubuntu-latest"
"steps":
- "name": "checkout"
"uses": "actions/checkout@v4"
- "name": "fix git dubious ownership"
"run": |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
- "if": "${{ !fromJSON(env.SKIP_VALIDATION) }}"
"name": "faillint"
"run": |
faillint -paths "sync/atomic=go.uber.org/atomic" ./...

"golangciLint":
"container":
"image": "${{ inputs.build_image }}"
"env":
Expand Down Expand Up @@ -112,10 +169,29 @@
"tar_args": "xvf"
"tarball_binary_path": "*/${binary}"
"version": "0.9.0"
- "if": "${{ !fromJSON(env.SKIP_VALIDATION) }}"
"name": "golangci-lint"
"uses": "golangci/golangci-lint-action@08e2f20817b15149a52b5b3ebe7de50aff2ba8c5"
"with":
"only-new-issues": true
"version": "${{ inputs.golang_ci_lint_version }}"
"integration":
"container":
"image": "${{ inputs.build_image }}"
"env":
"BUILD_IN_CONTAINER": false
"SKIP_VALIDATION": "${{ inputs.skip_validation }}"
"runs-on": "ubuntu-latest"
"steps":
- "name": "checkout"
"uses": "actions/checkout@v4"
- "name": "fix git dubious ownership"
"run": |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
- "if": "${{ !fromJSON(env.SKIP_VALIDATION) }}"
"name": "integration"
"run": "make test-integration"
"lint":
"lintFiles":
"container":
"image": "${{ inputs.build_image }}"
"env":
Expand Down Expand Up @@ -149,9 +225,6 @@
"tar_args": "xvf"
"tarball_binary_path": "*/${binary}"
"version": "0.9.0"
- "if": "${{ !fromJSON(env.SKIP_VALIDATION) }}"
"name": "lint"
"run": "make lint"
- "if": "${{ !fromJSON(env.SKIP_VALIDATION) }}"
"name": "lint scripts"
"run": "make lint-scripts"
Expand All @@ -160,13 +233,7 @@
"run": |
git fetch origin
make check-format
- "if": "${{ !fromJSON(env.SKIP_VALIDATION) }}"
"name": "golangci-lint"
"uses": "golangci/golangci-lint-action@08e2f20817b15149a52b5b3ebe7de50aff2ba8c5"
"with":
"only-new-issues": true
"version": "${{ inputs.golang_ci_lint_version }}"
"test":
"testLambdaPromtail":
"container":
"image": "${{ inputs.build_image }}"
"env":
Expand All @@ -176,33 +243,54 @@
"steps":
- "name": "checkout"
"uses": "actions/checkout@v4"
- "name": "pull release library code"
"uses": "actions/checkout@v4"
"with":
"path": "lib"
"ref": "${{ env.RELEASE_LIB_REF }}"
"repository": "grafana/loki-release"
- "name": "fix git dubious ownership"
"run": |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
- "if": "${{ !fromJSON(env.SKIP_VALIDATION) }}"
"name": "install tar"
"name": "test push package"
"run": |
apt update
apt install -qy tar xz-utils
gotestsum -- -covermode=atomic -coverprofile=coverage.txt -p=4 ./...
"working-directory": "tools/lambda-promtail"
"testPackages":
"container":
"image": "${{ inputs.build_image }}"
"env":
"BUILD_IN_CONTAINER": false
"SKIP_VALIDATION": "${{ inputs.skip_validation }}"
"needs":
- "collectPackages"
"runs-on": "ubuntu-latest"
"steps":
- "name": "checkout"
"uses": "actions/checkout@v4"
- "name": "fix git dubious ownership"
"run": |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
- "if": "${{ !fromJSON(env.SKIP_VALIDATION) }}"
"name": "install shellcheck"
"uses": "./lib/actions/install-binary"
"with":
"binary": "shellcheck"
"download_url": "https://github.com/koalaman/shellcheck/releases/download/v${version}/shellcheck-v${version}.linux.x86_64.tar.xz"
"smoke_test": "${binary} --version"
"tar_args": "xvf"
"tarball_binary_path": "*/${binary}"
"version": "0.9.0"
"name": "test ${{ matrix.package }}"
"run": |
gotestsum -- -covermode=atomic -coverprofile=coverage.txt -p=4 ./${{ matrix.package }}/...
"strategy":
"matrix":
"package": "${{fromJson(needs.collectPackages.outputs.packages)}}"
"testPushPackage":
"container":
"image": "${{ inputs.build_image }}"
"env":
"BUILD_IN_CONTAINER": false
"SKIP_VALIDATION": "${{ inputs.skip_validation }}"
"runs-on": "ubuntu-latest"
"steps":
- "name": "checkout"
"uses": "actions/checkout@v4"
- "name": "fix git dubious ownership"
"run": |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
- "if": "${{ !fromJSON(env.SKIP_VALIDATION) }}"
"name": "test"
"run": "make test"
"name": "test push package"
"run": |
gotestsum -- -covermode=atomic -coverprofile=coverage.txt -p=4 ./...
"working-directory": "pkg/push"
"name": "check"
"on":
"workflow_call":
Expand Down Expand Up @@ -234,4 +322,4 @@
"permissions":
"contents": "write"
"id-token": "write"
"pull-requests": "write"
"pull-requests": "write"
2 changes: 1 addition & 1 deletion .github/workflows/gel-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -209,4 +209,4 @@
"permissions":
"contents": "write"
"id-token": "write"
"pull-requests": "write"
"pull-requests": "write"
2 changes: 1 addition & 1 deletion .github/workflows/release-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -314,4 +314,4 @@ name: "Create Release PR"
permissions:
contents: "write"
id-token: "write"
pull-requests: "write"
pull-requests: "write"
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -218,4 +218,4 @@ name: "Create Release"
permissions:
contents: "write"
id-token: "write"
pull-requests: "write"
pull-requests: "write"
2 changes: 1 addition & 1 deletion .github/workflows/test-release-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -315,4 +315,4 @@ name: "Test Create Release PR Action"
permissions:
contents: "write"
id-token: "write"
pull-requests: "write"
pull-requests: "write"
2 changes: 2 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ linters-settings:
Main:
allow:
- fmt
- testing
- github.com/hashicorp/go-uuid
- github.com/stretchr/testify

misspell:
ignore-words:
Expand Down
18 changes: 18 additions & 0 deletions cmd/loki/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package main

import (
"testing"

"github.com/hashicorp/go-uuid"
"github.com/stretchr/testify/require"
)

func Test_Main(t *testing.T) {
t.Run("Test main", func(t *testing.T) {
require.True(t, true)

uid, err := uuid.GenerateUUID()
require.NoError(t, err)
require.NotEmpty(t, uid)
})
}
11 changes: 10 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,13 @@ go 1.21

toolchain go1.21.3

require github.com/hashicorp/go-uuid v1.0.3
require (
github.com/hashicorp/go-uuid v1.0.3
github.com/stretchr/testify v1.9.0
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
10 changes: 10 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8=
github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
16 changes: 16 additions & 0 deletions pkg/push/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module github.com/grafana/loki-release/pkg/push

go 1.21

toolchain go1.21.3

require (
github.com/hashicorp/go-uuid v1.0.3
github.com/stretchr/testify v1.9.0
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
12 changes: 12 additions & 0 deletions pkg/push/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8=
github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
18 changes: 18 additions & 0 deletions pkg/push/push_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package push

import (
"testing"

"github.com/hashicorp/go-uuid"
"github.com/stretchr/testify/require"
)

func Test_Push(t *testing.T) {
t.Run("Test main", func(t *testing.T) {
require.True(t, true)

uid, err := uuid.GenerateUUID()
require.NoError(t, err)
require.NotEmpty(t, uid)
})
}
15 changes: 15 additions & 0 deletions pkg/push/vendor/github.com/davecgh/go-spew/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading