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

Build IT image and use for ITs #497

Merged
merged 3 commits into from
Jul 3, 2021
Merged
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
10 changes: 5 additions & 5 deletions .github/actions/integration-test/action.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# action.yml
name: 'Flipt IT Tests'
description: 'Container for running Flipt ITs'
name: "Flipt IT Tests"
description: "Container for running Flipt ITs"
inputs:
args: # id of input
args: # id of input
description: args to pass to container'
required: true
runs:
using: 'docker'
image: 'Dockerfile'
using: "docker"
image: "docker://ghcr.io/markphelps/flipt-integration-test"
args:
- ${{ inputs.args }}
67 changes: 33 additions & 34 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Benchmark
on:
pull_request:
paths-ignore:
- '*.md'
- '*.yml'
- '.all-contributorsrc'
- "*.md"
- "*.yml"
- ".all-contributorsrc"

jobs:
benchmark:
Expand All @@ -15,8 +15,8 @@ jobs:
postgres:
image: postgres@sha256:c132d7802dcc127486a403fb9e9a52d9df2e3ab84037c5de8395ed6ba2743e20
ports:
# will assign a random free host port
- 5432/tcp
# will assign a random free host port
- 5432/tcp
# needed because the postgres container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
env:
Expand All @@ -27,47 +27,46 @@ jobs:
mysql:
image: mysql@sha256:a31a277d8d39450220c722c1302a345c84206e7fd4cdb619e7face046e89031d
ports:
# will assign a random free host port
- 3306/tcp
# will assign a random free host port
- 3306/tcp
env:
MYSQL_DATABASE: flipt_test
MYSQL_USER: mysql
MYSQL_PASSWORD: password
MYSQL_ALLOW_EMPTY_PASSWORD: true

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v2

- uses: actions/setup-go@v2
with:
go-version: '1.16.x'
- uses: actions/setup-go@v2
with:
go-version: "1.16.x"

- id: go-cache-paths
run: |
echo "::set-output name=go-build::$(go env GOCACHE)"
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
- id: go-cache-paths
run: |
echo "::set-output name=go-build::$(go env GOCACHE)"
echo "::set-output name=go-mod::$(go env GOMODCACHE)"

- name: Checkout
uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v2

- name: Go Build Cache
uses: actions/cache@v2
with:
path: ${{ steps.go-cache-paths.outputs.go-build }}
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
- name: Go Build Cache
uses: actions/cache@v2
with:
path: ${{ steps.go-cache-paths.outputs.go-build }}
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}

- name: Go Mod Cache
uses: actions/cache@v2
with:
path: ${{ steps.go-cache-paths.outputs.go-mod }}
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
- name: Go Mod Cache
uses: actions/cache@v2
with:
path: ${{ steps.go-cache-paths.outputs.go-mod }}
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}

- name: Benchmark (SQLite)
run: go test -bench=. ./... -run=XXX -v
- name: Benchmark (SQLite)
run: go test -bench=. ./... -run=XXX -v

- name: Benchmark (Postgres)
run: DB_URL="postgres://postgres:password@localhost:${{ job.services.postgres.ports['5432'] }}/flipt_test?sslmode=disable" go test -bench=. ./... -run=XXX -v

- name: Benchmark (MySQL)
run: DB_URL="mysql://mysql:password@localhost:${{ job.services.mysql.ports['3306'] }}/flipt_test" go test -bench=. ./... -run=XXX -v
- name: Benchmark (Postgres)
run: DB_URL="postgres://postgres:password@localhost:${{ job.services.postgres.ports['5432'] }}/flipt_test?sslmode=disable" go test -bench=. ./... -run=XXX -v

- name: Benchmark (MySQL)
run: DB_URL="mysql://mysql:password@localhost:${{ job.services.mysql.ports['3306'] }}/flipt_test" go test -bench=. ./... -run=XXX -v
88 changes: 44 additions & 44 deletions .github/workflows/database-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Database Tests
on:
pull_request:
paths-ignore:
- '*.md'
- '*.yml'
- '.all-contributorsrc'
- "*.md"
- "*.yml"
- ".all-contributorsrc"

jobs:
## Postgres Tests
Expand All @@ -16,8 +16,8 @@ jobs:
postgres:
image: postgres@sha256:c132d7802dcc127486a403fb9e9a52d9df2e3ab84037c5de8395ed6ba2743e20
ports:
# will assign a random free host port
- 5432/tcp
# will assign a random free host port
- 5432/tcp
# needed because the postgres container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
env:
Expand All @@ -26,34 +26,34 @@ jobs:
POSTGRES_PASSWORD: password

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v2

- uses: actions/setup-go@v2
with:
go-version: '1.16.x'
- uses: actions/setup-go@v2
with:
go-version: "1.16.x"

- id: go-cache-paths
run: |
echo "::set-output name=go-build::$(go env GOCACHE)"
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
- id: go-cache-paths
run: |
echo "::set-output name=go-build::$(go env GOCACHE)"
echo "::set-output name=go-mod::$(go env GOMODCACHE)"

- name: Checkout
uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v2

- name: Go Build Cache
uses: actions/cache@v2
with:
path: ${{ steps.go-cache-paths.outputs.go-build }}
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
- name: Go Build Cache
uses: actions/cache@v2
with:
path: ${{ steps.go-cache-paths.outputs.go-build }}
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}

- name: Go Mod Cache
uses: actions/cache@v2
with:
path: ${{ steps.go-cache-paths.outputs.go-mod }}
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
- name: Go Mod Cache
uses: actions/cache@v2
with:
path: ${{ steps.go-cache-paths.outputs.go-mod }}
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}

- name: Unit Test (Postgres)
run: DB_URL="postgres://postgres:password@localhost:${{ job.services.postgres.ports['5432'] }}/flipt_test?sslmode=disable" go test -count=1 -v ./...
- name: Unit Test (Postgres)
run: DB_URL="postgres://postgres:password@localhost:${{ job.services.postgres.ports['5432'] }}/flipt_test?sslmode=disable" go test -count=1 -v ./...

## MySQL Tests
mysql:
Expand All @@ -64,30 +64,30 @@ jobs:
mysql:
image: mysql@sha256:a31a277d8d39450220c722c1302a345c84206e7fd4cdb619e7face046e89031d
ports:
# will assign a random free host port
- 3306/tcp
# will assign a random free host port
- 3306/tcp
env:
MYSQL_DATABASE: flipt_test
MYSQL_USER: mysql
MYSQL_PASSWORD: password
MYSQL_ALLOW_EMPTY_PASSWORD: true

steps:
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: '1.16.x'
id: go
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: "1.16.x"
id: go

- name: Checkout
uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v2

- name: Restore Cache
uses: actions/cache@v1
id: cache
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-${{ hashFiles('**/go.sum') }}
- name: Restore Cache
uses: actions/cache@v1
id: cache
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-${{ hashFiles('**/go.sum') }}

- name: Unit Test (MySQL)
run: DB_URL="mysql://mysql:password@localhost:${{ job.services.mysql.ports['3306'] }}/flipt_test" go test -count=1 -v ./...
- name: Unit Test (MySQL)
run: DB_URL="mysql://mysql:password@localhost:${{ job.services.mysql.ports['3306'] }}/flipt_test" go test -count=1 -v ./...
51 changes: 51 additions & 0 deletions .github/workflows/integration-test-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Build/Push Integration Test Image
on:
push:
paths:
- "test/**"
- "Dockerfile.it"
workflow_dispatch:

jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-

- name: Login to GHCR
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and Push
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile.it
push: true
tags: ghcr.io/markphelps/flipt-integration-test:latest
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
# This ugly bit is necessary if you don't want your cache to grow forever
# till it hits GitHub's limit of 5GB.
# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
Loading