Improve CI #6
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: "Check Pull Request Quality Assurance" | |
on: # yamllint disable-line rule:truthy | |
- "pull_request" | |
env: | |
DEFAULT_DB_BACKEND: "postgresql" | |
DEFAULT_NAUTOBOT_VERSION: "stable" | |
DEFAULT_PYTHON_VERSION: "3.11" | |
concurrency: | |
group: "${{ github.workflow }}-${{ github.ref }}" | |
cancel-in-progress: true | |
jobs: | |
build: | |
runs-on: "ubuntu-22.04" | |
strategy: | |
fail-fast: true | |
matrix: | |
python-version: ["3.8", "3.11"] | |
db-backend: ["postgres"] | |
nautobot-version: ["stable"] | |
include: | |
- python-version: "3.11" | |
db-backend: "postgres" | |
nautobot-version: "2.0.0" | |
- python-version: "3.11" | |
db-backend: "mysql" | |
nautobot-version: "2.0.0" | |
env: | |
COMPOSE_FILE: "docker-compose.base.yml:docker-compose.${{ matrix.db-backend }}.yml:docker-compose.redis.yml:docker-compose.dev.yml" | |
NAUTOBOT_VER: "${{ matrix.nautobot-version }}" | |
PYTHON_VER: "${{ matrix.python-version }}" | |
steps: | |
- name: "Check out repository code" | |
uses: "actions/checkout@v4" | |
- name: "Configure" | |
id: "config" | |
run: | | |
# Read Docker image from Compose configuration into `image` output | |
cd development | |
cp creds.example.env creds.env | |
IMAGE="$(docker compose convert --format json | jq -r .services.nautobot.image)" | |
echo "image=${IMAGE}" >> $GITHUB_OUTPUT | |
cd - | |
# Determine if all tests should be run | |
if \ | |
[[ "${{ env.DEFAULT_DB_BACKEND }}" == "${{ matrix.db-backend }}" ]] && \ | |
[[ "${{ env.DEFAULT_NAUTOBOT_VERSION }}" == "${{ matrix.nautobot-version }}" ]] && \ | |
[[ "${{ env.DEFAULT_PYTHON_VERSION }}" == "${{ matrix.python-version }}" ]]; then \ | |
echo "all-tests=true" >> $GITHUB_OUTPUT | |
fi | |
- name: "Build" | |
run: | | |
cd development | |
docker compose build \ | |
--progress=plain \ | |
-- \ | |
nautobot | |
- name: "Simple Linters" | |
if: | | |
${{ steps.config.outputs.all-tests }} == 'true' | |
run: | | |
docker run \ | |
--rm \ | |
--entrypoint='' \ | |
--volume="$PWD:/source" \ | |
"${{ steps.config.outputs.image }}" \ | |
invoke black | |
- name: "pylint" | |
if: | | |
${{ steps.config.outputs.all-tests }} == 'true' | |
run: | | |
docker run \ | |
--rm \ | |
--entrypoint='' \ | |
--volume="$PWD:/source" \ | |
--env-file development/creds.env \ | |
--env-file development/development.env \ | |
"${{ steps.config.outputs.image }}" \ | |
invoke pylint | |
- name: "unittest" | |
run: | | |
cd development | |
docker compose run \ | |
--rm \ | |
--entrypoint='' \ | |
-- \ | |
nautobot \ | |
invoke unittest --failfast |