Skip to content

Commit

Permalink
TEST: Merge into one job
Browse files Browse the repository at this point in the history
  • Loading branch information
credbbl committed Nov 28, 2023
1 parent 562b3be commit 26892f1
Showing 1 changed file with 58 additions and 71 deletions.
129 changes: 58 additions & 71 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
name: glvd
name: build

on:
pull_request:
push:
branches:
- main
release:
types:
- published

permissions:
# Checkout repository
Expand All @@ -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:
Expand All @@ -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 }}'

0 comments on commit 26892f1

Please sign in to comment.