91 lines
2.5 KiB
YAML
91 lines
2.5 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
|
|
env:
|
|
DEFAULT_PYTHON: "3.10"
|
|
|
|
jobs:
|
|
code-quality:
|
|
runs-on: "ubuntu-latest"
|
|
name: Check code quality
|
|
steps:
|
|
- uses: "actions/checkout@v3"
|
|
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
|
|
id: python
|
|
uses: actions/setup-python@v4.2.0
|
|
with:
|
|
python-version: ${{ env.DEFAULT_PYTHON }}
|
|
cache: "pip"
|
|
cache-dependency-path: "requirements*"
|
|
- name: Install dependencies
|
|
run: |
|
|
pip install -r requirements.txt
|
|
pip install -r requirements-test.txt
|
|
# Following steps cannot run by pre-commit.ci as repo = local
|
|
- name: Run mypy
|
|
run: mypy bumper/
|
|
- name: Pylint review
|
|
run: pylint bumper/
|
|
|
|
tests:
|
|
runs-on: "ubuntu-latest"
|
|
name: Run tests
|
|
steps:
|
|
- uses: "actions/checkout@v3"
|
|
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
|
|
id: python
|
|
uses: actions/setup-python@v4.2.0
|
|
with:
|
|
python-version: ${{ env.DEFAULT_PYTHON }}
|
|
cache: "pip"
|
|
cache-dependency-path: "requirements*"
|
|
- name: Install dependencies
|
|
run: |
|
|
pip install -r requirements.txt
|
|
pip install -r requirements-test.txt
|
|
- name: Run pytest
|
|
run: pytest --cov=./ --cov-report=xml
|
|
- name: Upload coverage to Codecov
|
|
uses: codecov/codecov-action@v3
|
|
with:
|
|
fail_ci_if_error: true
|
|
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
packages: write
|
|
steps:
|
|
- name: checkout code
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Get tag name
|
|
shell: bash
|
|
run: |
|
|
BRANCH=$(echo ${GITHUB_REF#refs/heads/});
|
|
if [ -z $BRANCH ]; then
|
|
exit 1;
|
|
elif [ $BRANCH == "master" ]; then
|
|
BRANCH=latest;
|
|
fi
|
|
|
|
echo "##[set-output name=tag;]$(echo $BRANCH)"
|
|
id: tag_name
|
|
|
|
# https://github.com/docker/setup-qemu-action
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v2
|
|
|
|
# https://github.com/docker/setup-buildx-action
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v2
|
|
|
|
- name: Login to docker hub
|
|
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
|
|
|
|
- name: Build the image
|
|
run: |
|
|
docker buildx build --push \
|
|
--tag ghcr.io/edenhaus/bumper:${{ steps.tag_name.outputs.tag }} \
|
|
--platform linux/amd64,linux/arm/v7,linux/arm64 .
|