Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
51 changes: 51 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Run Tests

on:
push:
branches:
- main
pull_request:
branches:
- main
env:
AWS_REGION: eu-west-1
AWS_DEFAULT_REGION: eu-west-1
AWS_ACCESS_KEY_ID: DUMMYIDEXAMPLE
AWS_SECRET_ACCESS_KEY: DUMMYEXAMPLEKEY
AWS_SESSION_TOKEN: dummy

jobs:
test:
runs-on: ubuntu-latest
services:
dynamodb:
image: amazon/dynamodb-local
ports:
- 8000:8000
steps:
- name: Check out repository
uses: actions/checkout@v2
- name: Install Task
uses: arduino/setup-task@v2
with:
version: 3.x
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Create DynamoDB table
run: |
./docker/wait-for-db.sh
aws dynamodb create-table \
--region eu-west-1 \
--table-name clients \
--attribute-definitions AttributeName=clientId,AttributeType=S \
--key-schema AttributeName=clientId,KeyType=HASH \
--provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5 \
--endpoint-url http://localhost:8000 \
--no-cli-pager
- name: Set up gotestfmt
uses: gotesttools/gotestfmt-action@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Run tests
run: |
set -euo pipefail
go test -json -v ./... 2>&1 | tee /tmp/gotest.log | gotestfmt
3 changes: 1 addition & 2 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ tasks:
cmds: [go build -o build/server/idp-server cmd/server/main.go]
test:
desc: test project
cmds: [go test ./...]

cmds: [go test -v ./...]
10 changes: 10 additions & 0 deletions docker/wait-for-db.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
export AWS_ACCESS_KEY_ID="DUMMYIDEXAMPLE"
export AWS_SECRET_ACCESS_KEY="DUMMYEXAMPLEKEY"
export AWS_SESSION_TOKEN="dummy"
until aws --region us-east-1 --endpoint-url=http://localhost:8000 dynamodb list-tables; do
>&2 echo "DynamoDB is unavailable - sleeping"
sleep 1
done

echo "DynamoDB is available"
Loading