Skip to content

Commit

Permalink
First try with GitHub Actions reconfiguration
Browse files Browse the repository at this point in the history
  • Loading branch information
jennydaman committed Jul 23, 2024
1 parent 335143a commit ed16deb
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 92 deletions.
83 changes: 31 additions & 52 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Publish
name: Release

on:
push:
Expand All @@ -11,87 +11,66 @@ env:
jobs:
release:
name: Release
runs-on: ubuntu-latest
env:
POETRY_VERSION: '1.7.1'
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- name: Install rye
uses: eifinger/setup-rye@d4c3ac7b15d8bf2e0b45e2d257c6b5cdbebc3643 # v4.2.1
with:
python-version: '3.10'
# https://github.com/snok/install-poetry#caching-the-poetry-installation
- name: Load cached poetry installation
id: cached-poetry
uses: actions/cache@v4
with:
path: ~/.local
key: poetry-${{ env.POETRY_VERSION }}-0 # increment to reset cache
- name: Install Python Poetry
if: steps.cached-poetry.outputs.cache-hit != 'true'
uses: snok/install-poetry@c9e8b50048357a728ac0409bae3d7c0a1685118a
with:
version: ${{ env.POETRY_VERSION }}
version: '0.36.0'
enable-cache: true
cache-prefix: ${{ github.workflow }}

- name: Install
run: poetry install --all-extras
- name: Set version
run: rye version '${{ github.ref_name }}'
- run: rye sync
- name: Build
run: rye build --wheel --clean --verbose
- name: Publish
run: poetry publish --build --username='__token__' --password='${{ secrets.PYPI_API_TOKEN }}'
run: rye publish --yes --token '${{ secrets.PYPI_API_TOKEN }}' --verbose

- name: pdoc
run: |
poetry install --with=doc
poetry run pdoc \
rye run pdoc \
--logo '${{ env.logo }}' \
--footer-text='Version ${{ github.ref_name }}' \
--docformat numpy \
aiochris -o pdoc
- name: Deploy docs (version)
uses: JamesIves/github-pages-deploy-action@v4.5.0
uses: JamesIves/github-pages-deploy-action@v4.6.3
with:
branch: gh-pages
folder: pdoc
clean: true
clean-exclude: 'v*.*.*/'
target-folder: "${{ github.ref_name }}"
- name: Deploy docs (latest)
uses: JamesIves/github-pages-deploy-action@v4.5.0
uses: JamesIves/github-pages-deploy-action@v4.6.3
with:
branch: gh-pages
folder: pdoc
clean: false
- name: Get version
id: info
run: echo "version=$(poetry version | awk '{print $2}')" >> "$GITHUB_OUTPUT"
# ref: https://rye.astral.sh/guide/docker/
- name: Create Dockerfile
run: |
set -ex
poetry build
cd dist
wheel=$(echo ./aiochris-${{ steps.info.outputs.version }}-py3-*.whl)
if ! [ -f "$wheel" ]; then
echo "::error ::Not a file: $wheel"
exit 1
fi
now=$(date --rfc-3339=seconds)
cat > Dockerfile << EOF
FROM docker.io/library/python:3.11.5-alpine
python_version="$(< .python_version)"
version="$(rye version)"
now="$(date --rfc-3339=seconds)"
tee Dockerfile << EOF
FROM docker.io/library/python:${python_version}-alpine
LABEL org.opencontainers.image.created="$now" \
org.opencontainers.image.authors="Jennings Zhang, FNNDSC <[email protected]>" \
org.opencontainers.image.url="${{ github.server_url }}/${{ github.repository }}" \
org.opencontainers.image.documentation="https://fnndsc.github.io/aiochris" \
org.opencontainers.image.source="${{ github.server_url }}/${{ github.repository }}" \
org.opencontainers.image.version="${{ steps.info.outputs.version }}" \
org.opencontainers.image.documentation="https://fnndsc.github.io/aiochris/v$version/" \
org.opencontainers.image.version="$version" \
org.opencontainers.image.revision="${{ github.ref_name }}" \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.title="aiochris Python package" \
org.opencontainers.image.description="Python async client library for ChRIS"
COPY $wheel /tmp/$wheel
RUN pip install --no-input --no-cache-dir --disable-pip-version-check '/tmp/$wheel' && rm -v '/tmp/$wheel'
RUN --mount=source=dist,target=/dist PYTHONDONTWRITEBYTECODE=1 pip install --no-cache-dir /dist/*.whl
EOF
cat Dockerfile
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
Expand All @@ -102,20 +81,20 @@ jobs:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get version
id: get-version
run: echo "version=$(rye version)" >> "$GITHUB_OUTPUT"
- name: Build and push
uses: docker/build-push-action@v5
uses: docker/build-push-action@v6
with:
push: true
context: ./dist
tags: |
ghcr.io/fnndsc/aiochris:${{ steps.info.outputs.version }}
ghcr.io/fnndsc/aiochris:${{ steps.get-version.outputs.version }}
ghcr.io/fnndsc/aiochris:latest
platforms: linux/amd64,linux/ppc64le,linux/arm64
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache

- name: Draft Github Release
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
with:
draft: true
body: "https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/${{ github.ref_name }}"
54 changes: 15 additions & 39 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,62 +1,40 @@
name: test
name: Test

on:
push:
branches: [ master ]
pull_request:

jobs:
local:
test:
name: Tests
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
strategy:
matrix:
python-version: [ '3.11', '3.12' ]
env:
POETRY_VERSION: '1.7.1'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- name: Install rye
uses: eifinger/setup-rye@d4c3ac7b15d8bf2e0b45e2d257c6b5cdbebc3643 # v4.2.1
with:
python-version: '${{ matrix.python-version }}'
- name: Keyring dependencies
run: |
sudo apt update -y
sudo apt install -y gnome-keyring
# https://github.com/snok/install-poetry#caching-the-poetry-installation
- name: Load cached poetry installation
id: cached-poetry
uses: actions/cache@v4
with:
path: ~/.local
key: poetry-${{ env.POETRY_VERSION }}-0 # increment to reset cache
- name: Install Python Poetry
if: steps.cached-poetry.outputs.cache-hit != 'true'
uses: snok/install-poetry@c9e8b50048357a728ac0409bae3d7c0a1685118a
with:
version: ${{ env.POETRY_VERSION }}

- name: miniChRIS
version: '0.36.0'
enable-cache: true
cache-prefix: 'python-v${{ matrix.python-version }}'
- name: Set Python version
run: rye pin --no-update-requires-python '${{ matrix.python-version }}'
- run: rye sync
- name: Start miniChRIS
uses: FNNDSC/miniChRIS-docker@master

- name: Install
run: poetry install --all-extras --with=dev

- name: Test
id: test
continue-on-error: true # we want to upload coverage, even on failure
# Use wrapper script to access keyring
# https://github.com/hwchen/keyring-rs/blob/4297618e0cf061eacedf6d7c3f164ee4074a3c5d/linux-test.sh
run: |
cat > test.sh << EOF
rm -f $HOME/.local/share/keyrings/*
echo -n "test" | gnome-keyring-daemon --unlock
# retry tests: they might fail because of CUBE concurrency problems
for attempt in {1..5}; do
echo " +---------------------+ "
echo " | ATTEMPT $attempt | "
echo " +---------------------+ "
poetry run pytest --cov=aiochris --cov-report=xml
rye run pytest --cov=aiochris --cov-report=xml
if [ "$?" = 0 ]; then
if [ "$attempt" != "1" ]; then
echo "::warning ::Tests took $attempt attempts."
Expand All @@ -65,12 +43,10 @@ jobs:
fi
done
exit 1
EOF
dbus-run-session -- bash -x test.sh
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
files: ./coverage.xml
env_vars: 'python-${{ matrix.python-version }}'
- name: End test
run: '[ "${{ steps.test.outcome }}" = "success" ]'
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "aiochris"
version = "0.5.0a7"
version = "0.0.0"
description = "ChRIS client built on aiohttp"
authors = [
{ name = "Jennings Zhang", email = "[email protected]" },
Expand Down

0 comments on commit ed16deb

Please sign in to comment.