Skip to content

Commit

Permalink
feat: Update to Python3.11+Poetry on EL9 (#306)
Browse files Browse the repository at this point in the history
  • Loading branch information
hairmare authored Jul 2, 2023
1 parent e513a9a commit 9fcb4de
Show file tree
Hide file tree
Showing 11 changed files with 1,321 additions and 200 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
Dockerfile
.gitignore
LICENSE
README.md
suisa_sendemeldung.conf
venv
42 changes: 5 additions & 37 deletions .github/workflows/lint-and-test.yaml
Original file line number Diff line number Diff line change
@@ -1,44 +1,12 @@
name: Lint and Test

on:
push:
branches-ignore:
- main
- gh-pages
pull_request:
branches:
- main

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.x'

- run: pip install -r requirements-dev.txt

- name: Run pre-commit
uses: pre-commit/[email protected]

pytest:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.x', '3.9' ]
name: Test python ${{ matrix.python-version }}
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- run: pip install -r requirements-dev.txt

- run: pytest
uses: radiorabe/actions/.github/workflows/[email protected]
test-python-poetry:
uses: radiorabe/actions/.github/workflows/[email protected]
109 changes: 16 additions & 93 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,99 +1,22 @@
name: Release

on:
push:
branches:
- main
tags:
- 'v*.*.*'
pull_request:
push:
branches: [main]
release:
types: [created]

jobs:
container:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Prepare additional Metadata
id: additional_meta
run: |
echo created=$(date -u +'%Y-%m-%dT%H:%M:%SZ') >> $GITHUB_OUTPUT
- name: Prepare Image Metadata
id: meta
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/radiorabe/suisasendemeldung
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
labels: |
name=suisasendemeldung
summary=${{ github.event.repository.description }}
url=${{ github.event.repository.html_url }}
vcs-ref=${{ github.sha }}
revision=${{ github.sha }}
release=${{ github.sha }}
build-date=${{ steps.additional_meta.outputs.created }}
io.k8s.display-name=RaBe SUISA Sendemeldung
io.k8s.description=${{ github.event.repository.description }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
if: github.event_name != 'pull_request'
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
id: docker_build
uses: docker/build-push-action@v4
with:
context: ./
file: ./Dockerfile
platforms: linux/amd64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

wheel:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.x'

- run: python -m pip install --upgrade pip

- run: pip install -r requirements-dev.txt

- name: Build Wheel
run: python setup.py sdist bdist_wheel

- name: Run twine
if: github.event_name != 'pull_request'
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.RABE_PYPI_TOKEN }}
TWINE_NON_INTERACTIVE: true
run: twine upload dist/*
release-container:
uses: radiorabe/actions/.github/workflows/[email protected]
with:
image: 'ghcr.io/radiorabe/suisasendemeldung'
name: suisasendemeldung
display-name: SUISA Sendemeldung
tags: rabe python suisa

python-poetry:
uses: radiorabe/actions/.github/workflows/[email protected]
secrets:
RABE_PYPI_TOKEN: ${{ secrets.RABE_PYPI_TOKEN }}
12 changes: 12 additions & 0 deletions .github/workflows/schedule.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Scheduled tasks

on:
schedule:
- cron: '13 12 * * *'
workflow_dispatch:

jobs:
schedule-trivy:
uses: radiorabe/actions/.github/workflows/[email protected]
with:
image-ref: 'ghcr.io/radiorabe/suisasendemeldung:latest'
18 changes: 12 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
FROM ghcr.io/radiorabe/s2i-python:1.1.0 AS build
FROM ghcr.io/radiorabe/s2i-python:2.0.0 AS build

COPY ./ $HOME
COPY --chown=1001:0 ./ /opt/app-root/src/

RUN python3 setup.py bdist_wheel
RUN python3.11 -m build .


FROM ghcr.io/radiorabe/python-minimal:1.0.7 AS app
FROM ghcr.io/radiorabe/python-minimal:2.0.0 AS app

COPY --from=build /opt/app-root/src/dist/*.whl /tmp/dist/

RUN python3 -mpip --no-cache-dir install /tmp/dist/*.whl \
RUN microdnf install -y \
python3.11-pip \
&& python -mpip --no-cache-dir install /tmp/dist/*.whl \
&& microdnf remove -y \
python3.11-pip \
python3.11-setuptools \
&& microdnf clean all \
&& rm -rf /tmp/dist/

# make requests use os ca certs that contain the RaBe root CA
ENV REQUESTS_CA_BUNDLE=/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem

USER nobody

ENTRYPOINT ["suisa_sendemeldung"]
CMD ["suisa_sendemeldung"]
Loading

0 comments on commit 9fcb4de

Please sign in to comment.