Skip to content

Commit

Permalink
more work
Browse files Browse the repository at this point in the history
  • Loading branch information
riccardopinosio committed Feb 2, 2024
1 parent 464e9b0 commit 08268ce
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 17 deletions.
13 changes: 13 additions & 0 deletions .ci/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
services:
hugo:
image: hugo:$commit_hash
build:
context: ./..
dockerfile: ./Dockerfile
volumes:
- $test_folder:/test
- $test_folder/../scripts/run-unit-tests-container.sh:/run-unit-tests-container.sh
environment:
- HOST_UID=$host_uid
- TEST_MODELS_FOLDER=/unittest/models
command: /run-unit-tests-container.sh
10 changes: 8 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# https://docs.github.com/en/actions

name: Create release

on:
Expand All @@ -11,6 +9,14 @@ permissions:
contents: write

jobs:
test:
name: Run test suite
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Build and run tests
run: make run-tests
release:
name: Release pushed tag
runs-on: ubuntu-22.04
Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Run tests

on: workflow_dispatch

permissions:
contents: write

jobs:
test:
name: Run test suite
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Build and run tests
run: make run-tests
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ COPY --from=building /usr/lib/libtokenizers.a /usr/lib/libtokenizers.a
COPY --from=building /unittest /unittest
COPY --from=building /usr/local/bin/test2json /usr/local/bin/test2json
COPY --from=building /usr/local/bin/gotestsum /usr/local/bin/gotestsum

# copy over the test models
COPY ./models /unittest/models

ENV GOVERSION=$GO_VERSION
Expand Down
2 changes: 1 addition & 1 deletion scripts/run-unit-tests-container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

set -e

gotestsum --raw-command --junitfile "/test/unit/pipelines.xml" -- test2json -t -p pipelines /unittest/pipelines.test -test.v=test2json
gotestsum --raw-command --junitfile "/test/unit/pipelines.xml" --jsonfile "/test/unit/pipelines.json" -- test2json -t -p pipelines /unittest/pipelines.test -test.v=test2json
25 changes: 11 additions & 14 deletions scripts/run-unit-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,17 @@ set -e
this_dir="$( cd "$( dirname "$0" )" && pwd )"
src_dir="$(realpath "${this_dir}/..")"

commit_hash=$(git rev-parse --short HEAD)
docker build -f ./Dockerfile -t hugo:$commit_hash .
export commit_hash=$(git rev-parse --short HEAD)
export test_folder="$src_dir/testTarget"
mkdir -p $test_folder
export host_uid=$(id -u "$USER")

echo "Running tests for commit hash: $commit_hash"

mkdir -p $src_dir/testTarget
# build with compose
docker compose -f $src_dir/.ci/docker-compose.yaml build
# (cd $src_dir/.ci && docker compose build)

host_uid=$(id -u "$USER")
echo "Running tests for commit hash: $commit_hash"

docker run \
--rm \
-e HOST_UID=$host_uid \
-e TEST_MODELS_FOLDER=/unittest/models \
-v "$src_dir/testTarget:/test" \
-v "$this_dir/run-unit-tests-container.sh:/run-unit-tests-container.sh" \
"hugo:${commit_hash}" \
/run-unit-tests-container.sh
docker compose -f $src_dir/.ci/docker-compose.yaml up && \
docker compose -f $src_dir/.ci/docker-compose.yaml logs --no-color >& $test_folder/logs.txt && \
docker compose -f $src_dir/.ci/docker-compose.yaml rm -fsv

0 comments on commit 08268ce

Please sign in to comment.