Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
trevorwhitney committed Apr 19, 2024
1 parent b6e71c2 commit 4a89905
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 100 deletions.
43 changes: 19 additions & 24 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,23 @@
"USE_GITHUB_APP_TOKEN": "${{ inputs.use_github_app_token }}"
"jobs":
"check":
"container":
"image": "${{ inputs.build_image }}"
"env":
"BUILD_IN_CONTAINER": false
"SKIP_VALIDATION": "${{ inputs.skip_validation }}"
"needs":
- "checkFiles"
- "faillint"
- "golangciLint"
- "lintFiles"
"runs-on": "ubuntu-latest"
"steps":
- "if": "${{ !fromJSON(env.SKIP_VALIDATION) }}"
"name": "checks passed"
"run": |
echo "All linting and checks passed"
"checkFiles":
"container":
"image": "${{ inputs.build_image }}"
"env":
Expand Down Expand Up @@ -171,22 +188,6 @@
- "if": "${{ !fromJSON(env.SKIP_VALIDATION) }}"
"name": "integration"
"run": "make test-integration"
"lint":
"container":
"image": "${{ inputs.build_image }}"
"env":
"BUILD_IN_CONTAINER": false
"SKIP_VALIDATION": "${{ inputs.skip_validation }}"
"needs":
- "golangciLint"
- "lintFiles"
- "faillint"
"runs-on": "ubuntu-latest"
"steps":
- "if": "${{ !fromJSON(env.SKIP_VALIDATION) }}"
"name": "linting passed"
"run": |
echo "All linting checks passed"
"lintFiles":
"container":
"image": "${{ inputs.build_image }}"
Expand Down Expand Up @@ -236,10 +237,10 @@
"BUILD_IN_CONTAINER": false
"SKIP_VALIDATION": "${{ inputs.skip_validation }}"
"needs":
- "integration"
- "testLambdaPromtail"
- "testPackages"
- "testPushPackage"
- "testLambdaPromtail"
- "integration"
"runs-on": "ubuntu-latest"
"steps":
- "if": "${{ !fromJSON(env.SKIP_VALIDATION) }}"
Expand Down Expand Up @@ -282,12 +283,6 @@
- "if": "${{ !fromJSON(env.SKIP_VALIDATION) }}"
"name": "test ${{ matrix.package }}"
"run": |
echo "current directory:"
pwd
echo "\ncurrent directory contents:"
ls
echo "\npackage directory contents:"
ls ./${{ matrix.package }}
gotestsum -- -covermode=atomic -coverprofile=coverage.txt -p=4 ./${{ matrix.package }}/...
"strategy":
"matrix":
Expand Down
156 changes: 80 additions & 76 deletions workflows/validate.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ local validationJob = _validationJob(false);
packages: '${{ steps.gather-tests.outputs.packages }}',
}),

integration: validationJob
+ job.withSteps([
common.checkout,
common.fixDubiousOwnership,
validationMakeStep('integration', 'test-integration'),
]),

testPackages: validationJob
+ job.withNeeds(['collectPackages'])
+ job.withStrategy({
Expand All @@ -67,27 +74,10 @@ local validationJob = _validationJob(false);
step.new('test ${{ matrix.package }}')
+ step.withIf('${{ !fromJSON(env.SKIP_VALIDATION) }}')
+ step.withRun(|||
echo "current directory:"
pwd
echo "\ncurrent directory contents:"
ls
echo "\npackage directory contents:"
ls ./${{ matrix.package }}
gotestsum -- -covermode=atomic -coverprofile=coverage.txt -p=4 ./${{ matrix.package }}/...
|||),
]),

testPushPackage: validationJob
+ job.withSteps([
common.checkout,
common.fixDubiousOwnership,
step.new('test push package')
+ step.withIf('${{ !fromJSON(env.SKIP_VALIDATION) }}')
+ step.withWorkingDirectory('pkg/push')
+ step.withRun(|||
gotestsum -- -covermode=atomic -coverprofile=coverage.txt -p=4 ./...
|||),
]),

testLambdaPromtail: validationJob
+ job.withSteps([
Expand All @@ -101,15 +91,25 @@ local validationJob = _validationJob(false);
|||),
]),

integration: validationJob
+ job.withSteps([
common.checkout,
common.fixDubiousOwnership,
validationMakeStep('integration', 'test-integration'),
]),
testPushPackage: validationJob
+ job.withSteps([
common.checkout,
common.fixDubiousOwnership,
step.new('test push package')
+ step.withIf('${{ !fromJSON(env.SKIP_VALIDATION) }}')
+ step.withWorkingDirectory('pkg/push')
+ step.withRun(|||
gotestsum -- -covermode=atomic -coverprofile=coverage.txt -p=4 ./...
|||),
]),

test: validationJob
+ job.withNeeds(['testPackages', 'testPushPackage', 'testLambdaPromtail', 'integration'])
+ job.withNeeds([
'integration',
'testLambdaPromtail',
'testPackages',
'testPushPackage',
])
+ job.withSteps([
step.new('tests passed')
+ step.withIf('${{ !fromJSON(env.SKIP_VALIDATION) }}')
Expand All @@ -118,18 +118,38 @@ local validationJob = _validationJob(false);
|||),
]),

golangciLint: setupValidationDeps(
checkFiles: setupValidationDeps(
validationJob
+ job.withSteps(
[
step.new('golangci-lint', 'golangci/golangci-lint-action@08e2f20817b15149a52b5b3ebe7de50aff2ba8c5')
+ job.withSteps([
validationMakeStep('check generated files', 'check-generated-files'),
validationMakeStep('check mod', 'check-mod'),
validationMakeStep('check docs', 'check-doc'),
validationMakeStep('validate example configs', 'validate-example-configs'),
validationMakeStep('validate dev cluster config', 'validate-dev-cluster-config'),
validationMakeStep('check example config docs', 'check-example-config-doc'),
validationMakeStep('check helm reference doc', 'documentation-helm-reference-check'),
validationMakeStep('check drone drift', 'check-drone-drift'),
]) + {
steps+: [
step.new('build docs website')
+ step.withIf('${{ !fromJSON(env.SKIP_VALIDATION) }}')
+ step.with({
version: '${{ inputs.golang_ci_lint_version }}',
'only-new-issues': true,
}),
+ step.withRun(|||
cat <<EOF | docker run \
--interactive \
--env BUILD_IN_CONTAINER \
--env DRONE_TAG \
--env IMAGE_TAG \
--volume .:/src/loki \
--workdir /src/loki \
--entrypoint /bin/sh "%s"
git config --global --add safe.directory /src/loki
mkdir -p /hugo/content/docs/loki/latest
cp -r docs/sources/* /hugo/content/docs/loki/latest/
cd /hugo && make prod
EOF
||| % 'grafana/docs-base:e6ef023f8b8'),
],
)
}
),

faillint:
Expand All @@ -145,6 +165,19 @@ local validationJob = _validationJob(false);
|||),
]),

golangciLint: setupValidationDeps(
validationJob
+ job.withSteps(
[
step.new('golangci-lint', 'golangci/golangci-lint-action@08e2f20817b15149a52b5b3ebe7de50aff2ba8c5')
+ step.withIf('${{ !fromJSON(env.SKIP_VALIDATION) }}')
+ step.with({
version: '${{ inputs.golang_ci_lint_version }}',
'only-new-issues': true,
}),
],
)
),

lintFiles: setupValidationDeps(
validationJob
Expand All @@ -161,48 +194,19 @@ local validationJob = _validationJob(false);
)
),

check: validationJob
+ job.withNeeds([
'checkFiles',
'faillint',
'golangciLint',
'lintFiles',
])
+ job.withSteps([
step.new('checks passed')
+ step.withIf('${{ !fromJSON(env.SKIP_VALIDATION) }}')
+ step.withRun(|||
echo "All linting and checks passed"
|||),
]),

lint: validationJob
+ job.withNeeds(['golangciLint', 'lintFiles', 'faillint'])
+ job.withSteps([
step.new('linting passed')
+ step.withIf('${{ !fromJSON(env.SKIP_VALIDATION) }}')
+ step.withRun(|||
echo "All linting checks passed"
|||),
]),

check: setupValidationDeps(
validationJob
+ job.withSteps([
validationMakeStep('check generated files', 'check-generated-files'),
validationMakeStep('check mod', 'check-mod'),
validationMakeStep('check docs', 'check-doc'),
validationMakeStep('validate example configs', 'validate-example-configs'),
validationMakeStep('validate dev cluster config', 'validate-dev-cluster-config'),
validationMakeStep('check example config docs', 'check-example-config-doc'),
validationMakeStep('check helm reference doc', 'documentation-helm-reference-check'),
validationMakeStep('check drone drift', 'check-drone-drift'),
]) + {
steps+: [
step.new('build docs website')
+ step.withIf('${{ !fromJSON(env.SKIP_VALIDATION) }}')
+ step.withRun(|||
cat <<EOF | docker run \
--interactive \
--env BUILD_IN_CONTAINER \
--env DRONE_TAG \
--env IMAGE_TAG \
--volume .:/src/loki \
--workdir /src/loki \
--entrypoint /bin/sh "%s"
git config --global --add safe.directory /src/loki
mkdir -p /hugo/content/docs/loki/latest
cp -r docs/sources/* /hugo/content/docs/loki/latest/
cd /hugo && make prod
EOF
||| % 'grafana/docs-base:e6ef023f8b8'),
],
}
),
}

0 comments on commit 4a89905

Please sign in to comment.