Skip to content

Merge pull request #433 from cfcurtis/patch-1 #1130

Merge pull request #433 from cfcurtis/patch-1

Merge pull request #433 from cfcurtis/patch-1 #1130

Workflow file for this run

name: Tests
on:
pull_request:
push:
branches:
- master
tags:
- "**"
env:
DOCKER_REGISTRY: ghcr.io
DOCKER_IMAGE: ${{ github.repository }}
jobs:
check-formatting:
name: Check formatting
runs-on: ubuntu-latest
container: debian:bullseye
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
apt-get update
apt-get install -y \
$(xargs < dependencies.apt.txt) \
python3-setuptools
python3 -m pip install \
black
- name: Run black
run: |
python3 -m black --check --diff .
- name: Run flake8
run: |
python3 -m flake8
check-typing:
name: Static type check
runs-on: ubuntu-latest
container: debian:bullseye
steps:
- uses: actions/checkout@v4
- name: Prime pip cache
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: |
pip-${{ runner.os }}-${{ hashFiles('requirements.txt') }}
restore-keys: |
pip-${{ runner.os }}-
- name: Install dependencies
run: |
apt-get update
apt-get install -y \
$(xargs < dependencies.apt.txt) \
python3-setuptools
python3 -m pip install \
mypy \
lxml-stubs
- name: Prime mypy cache
uses: actions/cache@v3
with:
path: .mypy_cache
key: |
mypy-${{ runner.os }}-${{ github.run_id }}
restore-keys: |
mypy-${{ runner.os }}-
- name: Run mypy check
run: |
python3 -m mypy \
--install-types \
--non-interactive \
src
build-and-test-container:
name: Build and test container
runs-on: ubuntu-20.04
permissions:
packages: write
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build container
id: docker_build
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
tags: ${{ env.DOCKER_IMAGE }}:build
push: false
load: true
cache-from: type=registry,ref=${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE }}:latest
cache-to: type=inline
- name: Run tests in container
run: |
docker run -v $PWD:$PWD -w $PWD --entrypoint bash ${{ env.DOCKER_IMAGE }}:build -c \
"apt-get install python3-coverage && python3 -m coverage run -m unittest discover --verbose --buffer"
- name: Submit code coverage to Coveralls.io
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
run: |
sudo apt-get install -y \
python3-setuptools
sudo python3 -m pip install \
coveralls
python3 -m coveralls
continue-on-error: true
- name: Login to registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push image to registry
if: github.event_name != 'pull_request'
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
tags: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE }}:latest
push: true
- name: Login to ghcr.io using Flathub credentials
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ secrets.FLATHUB_ORG_USER }}
password: ${{ secrets.FLATHUB_ORG_TOKEN }}
- name: Push image to the old location
if: github.event_name != 'pull_request'
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
tags: ghcr.io/flathub/flatpak-external-data-checker:latest
push: true