diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cb95f73..d746a40 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,13 +1,10 @@ -name: glvd +name: build on: pull_request: push: branches: - main - release: - types: - - published permissions: # Checkout repository @@ -16,51 +13,6 @@ permissions: jobs: build: runs-on: ubuntu-latest - steps: - - name: Checkout repo - uses: actions/checkout@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Build and export - uses: docker/build-push-action@v5 - with: - context: . - file: Containerfile - tags: glvd:${{ github.ref_type == 'tag' && github.ref_name || github.sha }} - outputs: type=docker,dest=/tmp/glvd.tar - - - name: Upload artifact - uses: actions/upload-artifact@v3 - with: - name: glvd - path: /tmp/glvd.tar - retention-days: 7 - - test: - name: test (${{ matrix.test.name }}) - needs: build - runs-on: ubuntu-latest - - env: - PGUSER: user - PGPASSWORD: password - PGHOST: localhost - PGPORT: 5432 - PGDATABASE: glvd_test - GLVD_IMAGE_TAG: "glvd:${{ github.ref_type == 'tag' && github.ref_name || github.sha }}" - - strategy: - fail-fast: false - matrix: - test: - - name: py.test - command: py.test-3 /usr/local/src - dependencies: ["python3-pytest", "python3-pytest-asyncio"] - - name: mypy - command: mypy --show-error-codes --namespace-packages /usr/local/src - dependencies: ["mypy", "python3-pytest", "python3-urllib3/experimental"] services: postgres: @@ -73,29 +25,64 @@ jobs: - 5432:5432 steps: - - name: Checkout repo - uses: actions/checkout@v3 + - name: Checkout repo + uses: actions/checkout@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Build image + id: build + uses: docker/build-push-action@v5 + with: + file: Containerfile + load: true + +# strategy: +# fail-fast: false +# matrix: +# test: +# - name: py.test +# command: py.test-3 /usr/local/src +# dependencies: ["python3-pytest", "python3-pytest-asyncio"] +# - name: mypy +# command: mypy --show-error-codes --namespace-packages /usr/local/src +# dependencies: ["mypy", "python3-pytest", "python3-urllib3/experimental"] - - name: Download artifact - uses: actions/download-artifact@v3 - with: - name: glvd - path: /tmp + - name: Run flake8 + if: ${{ always() }} + run: > + docker run + --network host + --rm + --entrypoint '["bash", "-e"]' + ${{ steps.build.outputs.imageid }} + 'apt install -y flake8 && + mypy --show-error-codes /usr/local/src' - - name: Load image - run: | - docker load --input /tmp/glvd.tar + - name: Run py.test + if: ${{ always() }} + run: > + docker run + --network host + --rm + --entrypoint '["bash", "-e"]' + --env PGUSER=user + --env PGPASSWORD=user + ${{ steps.build.outputs.imageid }} + 'apt install -y python3-pytest && + py.test /usr/local/src' - - name: Prepare environment variables - run: env > env.list + - name: Run mypy + if: ${{ always() }} + run: > + docker run + --network host + --rm + --entrypoint '["bash", "-e"]' + --env PGUSER=user + --env PGPASSWORD=user + ${{ steps.build.outputs.imageid }} + 'apt install -y mypy python3-pytest && + mypy --show-error-codes /usr/local/src' - - name: Run image ${{ env.GLVD_IMAGE_TAG }} for ${{ matrix.test.name }} - run: | - docker run \ - --network host \ - --rm \ - --env-file env.list \ - ${GLVD_IMAGE_TAG} \ - bash -c 'apt update && - apt install -y ca-certificates ${{ join(matrix.test.dependencies, ' ') }} && - ${{ matrix.test.command }}' \ No newline at end of file