Improve CI #16
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: "Test Feature Pull Request" | |
on: # yamllint disable-line rule:truthy | |
pull_request: {} | |
# workflow_dispatch: {} | |
concurrency: | |
group: "${{ github.workflow }}-${{ github.ref }}" | |
cancel-in-progress: true | |
env: | |
NAUTOBOT_VER: "stable" | |
PYTHON_VER: "3.11" | |
jobs: | |
build: | |
runs-on: "ubuntu-22.04" | |
outputs: | |
image: ${{ steps.build.outputs.image }} | |
steps: | |
- name: "Check out repository code" | |
uses: "actions/checkout@v4" | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: "Build" | |
id: "build" | |
uses: "./.github/actions/build" | |
with: | |
image-name: "ghcr.io/${{ github.repository }}/nautobot-dev" | |
image-tag: "pr-${{ github.event.pull_request.number }}-py${{ env.PYTHON_VER }}-${{ env.NAUTOBOT_VER }}" | |
nautobot-version: "${{ env.NAUTOBOT_VER }}" | |
python-version: "${{ env.PYTHON_VER }}" | |
push: true | |
linters: | |
needs: build | |
runs-on: "ubuntu-22.04" | |
steps: | |
- name: "Check out repository code" | |
uses: "actions/checkout@v4" | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: "Pull Image" | |
run: | | |
docker pull '${{ needs.build.outputs.image }}' | |
- name: "Run Linters" | |
run: | | |
docker run \ | |
--rm \ | |
--entrypoint='' \ | |
--volume="$PWD:/source" \ | |
--env-file development/creds.env \ | |
--env-file development/development.env \ | |
'${{ needs.build.outputs.image }}' \ | |
invoke tests --lint-only --no-test-docs | |
test-postgres: | |
needs: build | |
runs-on: "ubuntu-22.04" | |
steps: | |
- name: "Check out repository code" | |
uses: "actions/checkout@v4" | |
- name: "Configure" | |
id: "config" | |
env: | |
COMPOSE_FILE: "docker-compose.base.yml" | |
run: | | |
cd development | |
cp creds.example.env creds.env | |
IMAGE="$(docker compose convert --format json | jq -r .services.nautobot.image)" | |
echo "image=$IMAGE" >> $GITHUB_ENV | |
cd - | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: "Pull Image" | |
run: | | |
docker pull '${{ needs.build.outputs.image }}' | |
docker tag '${{ needs.build.outputs.image }}' '${{ steps.config.outputs.image }}' | |
- name: "Test with Postgres" | |
env: | |
COMPOSE_FILE: "docker-compose.base.yml:docker-compose.postgres.yml:docker-compose.redis.yml:docker-compose.dev.yml" | |
run: | | |
cd development | |
docker compose run \ | |
--rm \ | |
--entrypoint='' \ | |
-- \ | |
nautobot \ | |
invoke unittest --failfast |