Skip to content

Commit

Permalink
Run functional tests on freshly built container (#3367)
Browse files Browse the repository at this point in the history
* Run functional tests on freshly built container

* Load built image into docker

* Mount ini file with absolute path
  • Loading branch information
leplatrem authored Jan 26, 2024
1 parent 0028db3 commit 425b97d
Showing 1 changed file with 37 additions and 3 deletions.
40 changes: 37 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,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 @@ -148,17 +151,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 }}
- 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

0 comments on commit 425b97d

Please sign in to comment.