Skip to content

Commit

Permalink
ci: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
jta committed Jun 4, 2024
1 parent c1a918f commit a5c99bc
Show file tree
Hide file tree
Showing 14 changed files with 316 additions and 293 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
name: golangci-lint
name: Run linters
on:
push:
branches:
- main
pull_request:
jobs:
golangci-lint:
lint:
name: golangci-lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: sam-validate
run: |
make sam-validate
- name: golangci-lint
run: |
make go-lint-all
make go-lint
20 changes: 0 additions & 20 deletions .github/workflows/sam-validate.yaml

This file was deleted.

64 changes: 29 additions & 35 deletions .github/workflows/tests-integration.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
name: Run IAC Integration Tests
name: Run Integration Tests

on:
# push:
# branches:
# - main
# release.yaml runs the tests on commits to main
pull_request:
# pull_request:
workflow_dispatch:
inputs:
debug_enabled:
Expand All @@ -14,8 +10,13 @@ on:
required: false
default: false
workflow_call:
schedule:
- cron: '0 0 * * 1' # Monday at 00:00 UTC
#schedule:
#- cron: '0 0 * * 1' # Monday at 00:00 UTC

env:
AWS_REGION: us-west-2
S3_BUCKET_PREFIX: "${{ github.run_id }}-"
SAM_CLI_TELEMETRY: 0

jobs:
permission_check:
Expand All @@ -34,26 +35,29 @@ jobs:
echo "can-write=true" >> $GITHUB_OUTPUT
fi
prepare_matrix:
discover:
needs: [permission_check]
if: needs.permission_check.outputs.can-write == 'true'
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.find_hcl_files.outputs.matrix }}
tests: ${{ steps.find_hcl_files.outputs.matrix }}
steps:
- uses: actions/checkout@v4

- name: Setup the test matrix
id: find_hcl_files
run: |
cd integration && \
echo "matrix=$(ls tests/*.hcl | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT
echo "matrix=$(ls integration/tests | awk -F. '{print $1}' | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT
package:
needs: [permission_check]
if: needs.permission_check.outputs.can-write == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Fetch tags for versioning
run: git fetch --prune --unshallow --tags

- name: DCE Provision
uses: observeinc/github-action-dce@1.0.1
Expand All @@ -67,17 +71,14 @@ jobs:

- name: Create S3 Bucket for Artifacts
run: |
if ! aws s3api head-bucket --bucket "${{ github.run_id }}-$AWS_REGION" 2>/dev/null; then
aws s3 mb s3://"${{ github.run_id }}-$AWS_REGION" --region us-west-2
if ! aws s3api head-bucket --bucket "${{ env.S3_BUCKET_PREFIX }}${{ env.AWS_REGION }}" 2>/dev/null; then
aws s3 mb s3://"${{ env.S3_BUCKET_PREFIX }}${{ env.AWS_REGION }}" --region us-west-2
fi
env:
AWS_REGION: us-west-2
- name: Package SAM Applications
run: make sam-package-all
run: make sam-package
env:
AWS_REGION: us-west-2
S3_BUCKET_PREFIX: ${{ github.run_id }}
MAKEFLAGS: "-j 4"

- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
Expand All @@ -90,15 +91,15 @@ jobs:
with:
name: repo-and-sam-build
path: |
${{ github.workspace }}/.aws-sam/
${{ github.workspace }}/.aws-sam/build/regions
test-integration:
runs-on: ubuntu-latest
needs: [permission_check, prepare_matrix]
needs: [permission_check, discover, package]
if: needs.permission_check.outputs.can-write == 'true'
strategy:
matrix:
testfile: ${{fromJson(needs.prepare_matrix.outputs.matrix)}}
testfile: ${{fromJson(needs.discover.outputs.tests)}}
steps:
- name: DCE Use
id: dce_setup
Expand All @@ -114,17 +115,10 @@ jobs:
uses: actions/download-artifact@v4
with:
name: repo-and-sam-build
path: ${{ github.workspace }}/.aws-sam/
path: ${{ github.workspace }}/.aws-sam/build/regions

- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'

- name: Integration test for ${{ matrix.testfile }}
run: S3_BUCKET_PREFIX=${S3_BUCKET_PREFIX} TEST_ARGS='-filter=${{ matrix.testfile }} -verbose' make integration-test
env:
AWS_REGION: us-west-2
S3_BUCKET_PREFIX: ${{ github.run_id }}
- name: Run ${{ matrix.testfile }} integration test
run: TEST_ARGS='-verbose' make test-integration-${{ matrix.testfile }}

cleanup:
needs: [permission_check, test-integration]
Expand Down
26 changes: 0 additions & 26 deletions .github/workflows/tests-unit.yaml

This file was deleted.

21 changes: 9 additions & 12 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Run Go tests
name: Run tests

on:
push:
Expand All @@ -9,18 +9,15 @@ on:
pull_request:

jobs:
test:
strategy:
matrix:
go: [ 1.22.x ]
platform: [ ubuntu-latest ]
runs-on: ${{ matrix.platform }}
go-test:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
- name: Checkout code
uses: actions/checkout@v4
- name: Test
- name: Go unit tests
run: make go-test

integration:
needs: go-test
uses: ./.github/workflows/tests-integration.yaml
secrets: inherit
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
.aws-sam/
.*.swp
build/
.go
bin/

.terraform
terraform.tfstate
Expand Down
36 changes: 0 additions & 36 deletions .golangci.yaml

This file was deleted.

Loading

0 comments on commit a5c99bc

Please sign in to comment.