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

Run functional tests on freshly built container #3367

Merged
merged 3 commits into from
Jan 26, 2024
Merged
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
40 changes: 37 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ jobs:
name: Functional
needs: lint
runs-on: ubuntu-latest
env:
DOCKER_CACHE: /tmp/docker-cache
TEST_TAG: user/app:test

services:
postgres:
Expand Down Expand Up @@ -144,17 +147,48 @@ jobs:
- name: Install dependencies
run: |
make install-dev
make install-postgres

- name: Create database
env:
PGPASSWORD: postgres
run: |
psql -c "CREATE DATABASE testdb ENCODING 'UTF8' TEMPLATE template0;" -U postgres -h localhost

- name: Start Kinto
- run: mkdir ${DOCKER_CACHE}

- name: Compute cache key
# Create hash of hashes of checked in files not in Dockerignore
run: echo "CACHE_KEY=$(git ls-tree --full-tree -r HEAD | grep -v -f .dockerignore | awk '{print $3}' | git hash-object --stdin)" >> $GITHUB_ENV

- uses: actions/cache@v3
with:
path: ${{ env.DOCKER_CACHE}}
key: docker-build-${{ hashFiles('Dockerfile') }}-${{ env.CACHE_KEY }}
restore-keys: |
docker-build-${{ hashFiles('Dockerfile') }}-${{ env.CACHE_KEY }}
Comment on lines +159 to +168
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking forward to the day that there's an easier way to do this ...


- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
install: true

- name: Build container
uses: docker/build-push-action@v5
with:
cache-from: type=local,src=${{ env.DOCKER_CACHE}}
cache-to: type=local,dest=${{ env.DOCKER_CACHE}},mode=max
tags: ${{ env.TEST_TAG }}
file: Dockerfile
load: true
context: .

- name: Run container
run: |
make runkinto & sleep 5
docker run --net=host --detach --rm \
-p 8888:8888 \
-v `pwd`/tests/functional.ini:/etc/functional.ini \
-e KINTO_INI=/etc/functional.ini \
${{ env.TEST_TAG }} && sleep 5

- name: Functional Tests
run: |
Expand Down
Loading