From 4e83f49ba8f4a553e67b27ec23f1b0d25cdcfdc2 Mon Sep 17 00:00:00 2001 From: Izel Nakri Date: Fri, 4 Dec 2020 20:50:07 +0100 Subject: [PATCH] initial github-actions test --- .github/workflows/push.yml | 44 ++++++++++++++++++++++++++++++++++++++ docker-compose.yaml | 3 +-- 2 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/push.yml diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml new file mode 100644 index 00000000..645db854 --- /dev/null +++ b/.github/workflows/push.yml @@ -0,0 +1,44 @@ +# implement caching from latest(so no building redundant steps) +# use local cache on tests(so no pulling) +name: docker-compose-actions-workflow +on: push +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Set ENV variables + run: | + echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/} | tr / -)" >> $GITHUB_ENV + echo "DOCKER_TAG=paper_trail:$(echo ${GITHUB_REF#refs/heads/} | tr / -)" >> $GITHUB_ENV + - name: Expose .env to steps + run: | + sed -i $(echo "s/\$DOCKER_TAG/$DOCKER_TAG/g") .env + cat .env >> $GITHUB_ENV + - name: Docker-compose pull + run: docker-compose pull + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.HUB_USERNAME }} + password: ${{ secrets.HUB_KEY }} + - name: Build and push + uses: docker/build-push-action@v2 + with: + context: . + file: ./Dockerfile + push: true + tags: ${{ secrets.HUB_USERNAME }}/${{ env.DOCKER_TAG }} + cache-from: type=registry,ref=${{ secrets.HUB_USERNAME }}/${{ env.DOCKER_TAG }} + cache-to: type=inline + - name: Docker-compose up + run: docker-compose -f docker-compose.yaml up -d + - name: Execute tests + run: | + docker-compose exec -T paper_trail mix test test/paper_trail + docker-compose run paper_trail mix test test/version + docker-compose run paper_trail mix test test/uuid + STRING_TEST=true docker-compose run paper_trail mix test test/uuid diff --git a/docker-compose.yaml b/docker-compose.yaml index eeb3733d..571a8424 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -29,11 +29,10 @@ services: - db networks: - backend_network - command: ["./setup-database.sh"] + command: ["/bin/sh", "./setup-database.sh"] volumes: pgdata: networks: backend_network: driver: bridge -