Skip to content

Verify docker image working on CI #59

Verify docker image working on CI

Verify docker image working on CI #59

Workflow file for this run

on:
pull_request:
branches:
- main
push:
branches:
- main
jobs:
test:
runs-on: ubuntu-latest
permissions:
# This is required to push changes back to the repository
contents: write
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.22
- name: Start LocalStack
uses: LocalStack/setup-localstack@v0.2.2
with:
image-tag: 'latest'
install-awslocal: 'true'
- name: Set up Git user
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "aws-checker@@users.noreply.github.com"
- name: Bump Go versions in go.mod and workflows if necessary
run: go run ./tools/syncgover
- name: Run tests
run: go test -v ./...
env:
# localstack requires these environment variables
AWS_DEFAULT_REGION: ap-northeast-1
# Credentials are important for localstack
# Without them, the tests will fail like:
# operation error S3: CreateBucket, get identity: get credentials: failed to refresh cached credentials, no EC2 IMDS role found, operation error ec2imds: GetMetadata, failed to get API token, operation error ec2imds: getToken, http response error StatusCode: 400, request to EC2 IMDS failed
AWS_ACCESS_KEY_ID: test
AWS_SECRET_ACCESS_KEY: test
# These environment variables are required by main and main_test
# Without them, the tests will fail like:
# operation error S3: CreateBucket, exceeded maximum number of attempts, 3, https response error StatusCode: 500, RequestID: 346f5995-bbe8-41e2-be03-3a6ab0ad5edd, HostID: s9lzHYrFp76ZVxRcpX9+5cjAnEH2ROuNkd2BHfIa6UkFVdtjf5mKR3/eTPFvsiP/XV/VLi31234=, api error InternalError: exception while calling s3 with unknown operation: Unable to find operation for request to service s3: PUT /
S3_BUCKET: mybucket
S3_KEY: mykey
# This one is for setupDynamoDBTable in main_test
DYNAMODB_TABLE: mytable
# This one is for setupSQSQueue in main_test
SQS_QUEUE_URL: https://sqs.ap-northeast-1.amazonaws.com/123456789012/myqueue
- name: Push code changes back to the repository
if: github.event_name == 'pull_request'
run: |
echo Pushing changes to ${GITHUB_HEAD_REF}
git push origin HEAD:${GITHUB_HEAD_REF} || echo "Unable to push changes"
goreleaser:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.22
- name: Goreleaser image building test
uses: goreleaser/goreleaser-action@v6
with:
args: release --snapshot
- name: Verify docker images working
run: docker run --rm ghcr.io/chatwork/aws-checker:canary-amd64 aws-checker version