Skip to content

Commit

Permalink
Merge pull request #184 from rackerlabs/workflow-pkg
Browse files Browse the repository at this point in the history
feat: workflows python package and common container for them
  • Loading branch information
cardoe authored Jul 31, 2024
2 parents 86f2e45 + 51a0e9e commit e41e591
Show file tree
Hide file tree
Showing 44 changed files with 1,999 additions and 402 deletions.
23 changes: 0 additions & 23 deletions .github/workflows/build-container-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@ on:
env:
VERSION_PYTHON311: 0.0.1
VERSION_PYTHON312: 0.0.1
VERSION_PYTHON_IRONIC: 0.0.4
VERSION_ARGO_UTILS: 0.0.1
VERSION_OBM_UTILS: 0.0.1
VERSION_PYTHON_NAUTOBOT_INT_SYNC: 0.0.1
VERSION_PYTHON_NAUTOBOT: 0.0.1

jobs:
Expand Down Expand Up @@ -67,17 +65,6 @@ jobs:
labels: |
org.opencontainers.image.version=${{ env.VERSION_PYTHON312 }}
- name: Build and deploy Python 3.11 with Ironic client
uses: docker/build-push-action@v5
with:
context: argo-workflows/sync-nb-server-to-ironic
file: argo-workflows/sync-nb-server-to-ironic/containers/Dockerfile.ironic
# push for all main branch commits
push: ${{ github.event_name != 'pull_request' }}
tags: ghcr.io/rackerlabs/understack/argo-ironic-client-python3.11.8:latest,ghcr.io/rackerlabs/understack/argo-ironic-client-python3.11.8:${{ env.VERSION_PYTHON_IRONIC }}
labels: |
org.opencontainers.image.version=${{ env.VERSION_PYTHON_IRONIC }}
- name: Build and deploy Argo Utils image
uses: docker/build-push-action@v5
with:
Expand All @@ -100,16 +87,6 @@ jobs:
labels: |
org.opencontainers.image.version=${{ env.VERSION_OBM_UTILS }}
- name: Build and deploy Python 3.11 with Nautobot Int Sync
uses: docker/build-push-action@v5
with:
context: argo-workflows/sync-srv-redfish-intfs-to-nb
file: argo-workflows/sync-srv-redfish-intfs-to-nb/containers/Dockerfile.nautobot_int_sync
# push for all main branch commits
push: ${{ github.event_name != 'pull_request' }}
tags: ghcr.io/rackerlabs/understack/nautobot-interfaces-sync:latest,ghcr.io/rackerlabs/understack/nautobot-interfaces-sync:${{ env.VERSION_PYTHON_NAUTOBOT_INT_SYNC }}
labels: |
org.opencontainers.image.version=${{ env.VERSION_PYTHON_NAUTOBOT_INT_SYNC }}
- name: Build and deploy Python 3.11 with PyNautobot nautobot-update-cf
uses: docker/build-push-action@v5
with:
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/code-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: code tests

on:
push:
branches:
- main
paths:
- "python/**"
- ".github/workflows/code-test.yaml"
pull_request:
paths:
- "python/**"
- ".github/workflows/code-test.yaml"
workflow_dispatch:

jobs:
understack-workflows:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./python/understack-workflows

steps:
- uses: actions/checkout@v4
- run: pipx install poetry==1.7.1 && poetry self add 'poetry-dynamic-versioning[plugin]'
- uses: actions/setup-python@v5
with:
python-version-file: python/understack-workflows/pyproject.toml
cache: "poetry"
- run: poetry install --sync --with test
- run: poetry build
- run: poetry run pytest
47 changes: 47 additions & 0 deletions .github/workflows/containers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,50 @@ jobs:
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

workflows:
runs-on: ubuntu-latest

strategy:
matrix:
container:
- name: ironic-nautobot-client
title: Understack Ironic Nautobot Clients

steps:
- name: setup docker buildx
uses: docker/setup-buildx-action@v3
- name: login to ghcr.io
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: image metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/rackerlabs/understack/${{ matrix.container.name }}
labels: |
org.opencontainers.image.title=${{ matrix.container.title }}
env:
# Create the annotations at the index as well since this
# defaults to manifest only and we have to manually merge
# the container is multi-arch because of provenance creating
# an 'unknown/unknown' arch with data. We've got no annotations
# that are arch specific so populate them at the index as well.
DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index

- name: build and deploy container image to registry
uses: docker/build-push-action@v5
with:
file: containers/Dockerfile.${{ matrix.container.name }}
pull: true # ensure we always have an up to date source
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.annotations }}
# prod is the target that has the code installed
target: prod
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@ components/01-secrets/kustomization.yaml
.venv/
venv/
.python-version

# python packaging
*.egg-info
/python/*/build/
/python/*/dist/
__pycache__
23 changes: 23 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ repos:
rev: 7.0.0
hooks:
- id: flake8
exclude: '^python/'
args:
- --max-line-length=120
- repo: https://github.com/psf/black
rev: 24.4.2
hooks:
- id: black
exclude: '^python/'
args:
- --line-length=120
- --check
Expand All @@ -38,3 +40,24 @@ repos:
rev: v1.22.8
hooks:
- id: typos
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.4
hooks:
- id: ruff
files: '^python/'
args: [--fix]
- id: ruff-format
files: '^python/'
- repo: https://github.com/python-poetry/poetry
rev: '1.7.1'
hooks:
- id: poetry-check
language_version: "3.11"
name: "poetry-check (understack-workflows)"
files: '^python/understack-workflows/'
args: ["-C", "python/understack-workflows"]
- id: poetry-lock
language_version: "3.11"
name: "poetry-lock (understack-workflows)"
files: '^python/understack-workflows/'
args: ["-C", "python/understack-workflows", "--no-update"]

This file was deleted.

100 changes: 0 additions & 100 deletions argo-workflows/sync-nb-server-to-ironic/code/synchronize-obm-creds.py

This file was deleted.

89 changes: 0 additions & 89 deletions argo-workflows/sync-nb-server-to-ironic/code/synchronize-server.py

This file was deleted.

Loading

0 comments on commit e41e591

Please sign in to comment.