diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..95190ae --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,76 @@ +name: Test + +on: + pull_request: + release: + types: + - published + +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:latest + 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: + needs: build + runs-on: ubuntu-latest + + env: + DATABASE_URL: postgres://user:password@localhost:5432/glvd_test + + services: + postgres: + image: postgres + env: + POSTGRES_DB: glvd_test + POSTGRES_USER: user + POSTGRES_PASSWORD: password + ports: + - 5432:5432 + + steps: + - name: Checkout repo + uses: actions/checkout@v3 + + - name: Download artifact + uses: actions/download-artifact@v3 + with: + name: glvd + path: /tmp + + - name: Load image + run: | + docker load --input /tmp/glvd.tar + + - name: Run image + run: | + docker run \ + --env RAILS_ENV=test \ + --env DATABASE_URL="$DATABASE_URL" \ + --network host \ + --rm \ + glvd:latest \ + sudo apt update && \ + sudo apt install -y ca-certificates python3-pytest python3-pytest-flake8 mypy && \ + py.test-3 --flake8 /usr/local/src && \ + mypy --show-error-codes --namespace-packages /usr/local/src \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 9f8395d..d3659e8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,7 +23,7 @@ pytest-asyncio = ">=0.20" requests-mock = ">=1.9" [tool.pytest.ini_options] -minversion = "7.0" +minversion = "6.0" addopts = [ "--import-mode=importlib", ]