Refactor GitHub Actions workflows; add new workflows for Poetry and uv
This commit is contained in:
63
.github/workflows/docker-publish.yml
vendored
63
.github/workflows/docker-publish.yml
vendored
@ -1,77 +1,58 @@
|
|||||||
name: Docker
|
name: Docker
|
||||||
|
|
||||||
on:
|
on:
|
||||||
schedule:
|
|
||||||
- cron: "20 6 * * *"
|
|
||||||
push:
|
push:
|
||||||
branches: [master]
|
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [master]
|
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
schedule:
|
||||||
|
- cron: "0 6 * * *"
|
||||||
|
|
||||||
env:
|
env:
|
||||||
BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
|
BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
|
||||||
TIMEZONE: Europe/Stockholm
|
TIMEZONE: Europe/Stockholm
|
||||||
LOG_LEVEL: Info
|
LOG_LEVEL: Info
|
||||||
SQLITE_LOCATION: /data/jobs.sqlite
|
SQLITE_LOCATION: /data/jobs.sqlite
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build-and-push-docker:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
packages: write
|
packages: write
|
||||||
steps:
|
steps:
|
||||||
- name: Download code
|
- run: |
|
||||||
uses: actions/checkout@v4
|
if [ -z "${{ env.BOT_TOKEN }}" ]; then
|
||||||
|
echo "BOT_TOKEN not set"
|
||||||
- name: Set up QEMU for cross-platform Docker images
|
exit 1
|
||||||
uses: docker/setup-qemu-action@v3
|
fi
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: astral-sh/setup-uv@v5
|
||||||
|
with:
|
||||||
|
python-version: 3.13
|
||||||
|
- run: uv sync --all-extras --dev
|
||||||
|
- run: uv run pytest
|
||||||
|
- uses: docker/setup-qemu-action@v3
|
||||||
with:
|
with:
|
||||||
platforms: all
|
platforms: all
|
||||||
|
- uses: docker/setup-buildx-action@v3
|
||||||
- name: Set up Docker Buildx
|
- uses: docker/login-action@v3
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
|
|
||||||
- name: Install Poetry
|
|
||||||
run: pipx install poetry
|
|
||||||
|
|
||||||
- name: Setup Python 3.11
|
|
||||||
uses: actions/setup-python@v5
|
|
||||||
with:
|
|
||||||
python-version: "3.11"
|
|
||||||
cache: "poetry"
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: poetry install
|
|
||||||
|
|
||||||
- name: Run tests
|
|
||||||
run: poetry run pytest
|
|
||||||
|
|
||||||
- name: Login to Docker Hub
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
if: github.event_name != 'pull_request'
|
if: github.event_name != 'pull_request'
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
- uses: docker/login-action@v3
|
||||||
- name: Login to GitHub Container Registry
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
if: github.event_name != 'pull_request'
|
if: github.event_name != 'pull_request'
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
username: ${{ github.repository_owner }}
|
username: ${{ github.repository_owner }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
- uses: docker/build-push-action@v6
|
||||||
- name: Build and push Docker image to Docker Hub
|
|
||||||
uses: docker/build-push-action@v5
|
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
platforms: linux/amd64, linux/arm64
|
platforms: linux/amd64, linux/arm64
|
||||||
push: ${{ github.event_name != 'pull_request' }}
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
tags: thelovinator/discord-reminder-bot:latest
|
tags: thelovinator/discord-reminder-bot:latest
|
||||||
|
- uses: docker/build-push-action@v6
|
||||||
- name: Build and push Docker image to GitHub Container Registry
|
|
||||||
uses: docker/build-push-action@v5
|
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
platforms: linux/amd64, linux/arm64
|
platforms: linux/amd64, linux/arm64
|
||||||
|
38
.github/workflows/poetry.yml
vendored
Normal file
38
.github/workflows/poetry.yml
vendored
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
name: Poetry
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
pull_request:
|
||||||
|
workflow_dispatch:
|
||||||
|
schedule:
|
||||||
|
- cron: "0 6 * * *"
|
||||||
|
|
||||||
|
env:
|
||||||
|
BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
|
||||||
|
TIMEZONE: Europe/Stockholm
|
||||||
|
LOG_LEVEL: Info
|
||||||
|
SQLITE_LOCATION: /data/jobs.sqlite
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test-on-poetry:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
python-version: ["3.10", "3.11", "3.12", "3.13"]
|
||||||
|
poetry-version: ["latest", "main"]
|
||||||
|
steps:
|
||||||
|
- run: |
|
||||||
|
if [ -z "${{ env.BOT_TOKEN }}" ]; then
|
||||||
|
echo "BOT_TOKEN not set"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/setup-python@v5
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-version }}
|
||||||
|
- uses: abatilo/actions-poetry@v4
|
||||||
|
with:
|
||||||
|
poetry-version: ${{ matrix.poetry-version }}
|
||||||
|
- run: poetry install
|
||||||
|
- run: poetry run pytest
|
41
.github/workflows/uv.yml
vendored
Normal file
41
.github/workflows/uv.yml
vendored
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
name: uv
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
pull_request:
|
||||||
|
workflow_dispatch:
|
||||||
|
schedule:
|
||||||
|
- cron: "0 6 * * *"
|
||||||
|
|
||||||
|
env:
|
||||||
|
BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
|
||||||
|
TIMEZONE: Europe/Stockholm
|
||||||
|
LOG_LEVEL: Info
|
||||||
|
SQLITE_LOCATION: /data/jobs.sqlite
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test-on-uv:
|
||||||
|
name: Install with uv and run tests on Python ${{ matrix.python-version }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
python-version: ["3.10", "3.11", "3.12", "3.13"]
|
||||||
|
steps:
|
||||||
|
- run: |
|
||||||
|
if [ -z "${{ env.BOT_TOKEN }}" ]; then
|
||||||
|
echo "BOT_TOKEN not set"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Install uv and set the python version to ${{ matrix.python-version }}
|
||||||
|
uses: astral-sh/setup-uv@v5
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-version }}
|
||||||
|
version: "latest"
|
||||||
|
- name: Install dependencies
|
||||||
|
run: uv sync --all-extras --dev
|
||||||
|
- name: Run tests
|
||||||
|
run: uv run pytest
|
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@ -7,9 +7,11 @@
|
|||||||
"audioop",
|
"audioop",
|
||||||
"autouse",
|
"autouse",
|
||||||
"botuser",
|
"botuser",
|
||||||
|
"Buildx",
|
||||||
"cookiejar",
|
"cookiejar",
|
||||||
"dateparser",
|
"dateparser",
|
||||||
"delenv",
|
"delenv",
|
||||||
|
"DOCKERHUB",
|
||||||
"docstrings",
|
"docstrings",
|
||||||
"dotenv",
|
"dotenv",
|
||||||
"filterwarnings",
|
"filterwarnings",
|
||||||
|
@ -144,6 +144,3 @@ log_cli_level = "INFO"
|
|||||||
log_cli_format = "%(asctime)s [%(levelname)8s] %(message)s (%(filename)s:%(lineno)s)"
|
log_cli_format = "%(asctime)s [%(levelname)8s] %(message)s (%(filename)s:%(lineno)s)"
|
||||||
log_cli_date_format = "%Y-%m-%d %H:%M:%S"
|
log_cli_date_format = "%Y-%m-%d %H:%M:%S"
|
||||||
filterwarnings = ["ignore::DeprecationWarning:aiohttp.cookiejar"]
|
filterwarnings = ["ignore::DeprecationWarning:aiohttp.cookiejar"]
|
||||||
|
|
||||||
# [tool.uv.sources]
|
|
||||||
# discord-py = {git = "https://github.com/Rapptz/discord.py"}
|
|
||||||
|
Reference in New Issue
Block a user