ALEPH-7 project modernization: migrate project to python 3.12, hatch, pyproject.toml, upgrade dependencies, migrate to latest pytezos and add a bunch of other improvements and some documentation improvement. #1548
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
# This workflow will install Python dependencies, run tests and lint with a single version of Python | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | |
name: Unit tests | |
on: | |
push: | |
branches: | |
- dev | |
- main | |
pull_request: | |
branches: | |
- "*" | |
jobs: | |
tests: | |
runs-on: ubuntu-22.04 | |
services: | |
postgres: | |
image: postgres:15.1 | |
ports: | |
- 5432:5432 | |
env: | |
POSTGRES_USER: aleph | |
POSTGRES_PASSWORD: decentralize-everything | |
POSTGRES_DATABASE: aleph | |
redis: | |
image: redis:7.0.10 | |
ports: | |
- 127.0.0.1:6379:6379 | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
# Fetch the whole history for all tags and branches (required for aleph.__version__) | |
fetch-depth: 0 | |
- name: Set up Python 3.11 | |
id: setup-python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.11 | |
- name: Install latest Rust nightly toolchain | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: nightly | |
override: true | |
components: rustfmt, clippy | |
- name: Get pip cache dir | |
id: pip-cache | |
run: | | |
echo "::set-output name=dir::$(pip cache dir)" | |
- name: "install hatch" | |
run: | | |
pip install hatch | |
- uses: actions/cache@v2 | |
with: | |
path: ${{ steps.pip-cache.outputs.dir }} | |
key: ${{ runner.os }}-python-${{ steps.setup-python.outputs.python-version }}-pip-${{ hashFiles('setup.cfg') }} | |
- name: Install Python dependencies | |
run: | | |
rustup default nightly # Required to build some dependencies | |
pip install wheel | |
pip install --upgrade .[testing] | |
- name: Run unit tests | |
run: | | |
sudo cp .github/openssl-ci.cnf /etc/ssl/openssl.cnf | |
export OPENSSL_CONF=/etc/ssl/openssl.cnf | |
touch config.yml # Fake config file for alembic | |
# TODO: determine why ResourceWarning warnings occur in some tests. | |
hatch run testing:cov | |
- name: Upload coverage reports to Codecov | |
uses: codecov/[email protected] | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
slug: aleph-im/pyaleph | |
build: | |
runs-on: ubuntu-22.04 | |
needs: tests | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- uses: actions/checkout@v2 | |
- name: Log in to registry | |
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | |
- name: Download Docker cache image (if available) | |
run: docker pull ghcr.io/$GITHUB_REPOSITORY/build-cache || true | |
- name: Build the Docker image | |
run: | | |
git fetch --prune --unshallow --tags | |
docker build . -t pyaleph-node:${GITHUB_REF##*/} -f deployment/docker-build/pyaleph.dockerfile --cache-from=ghcr.io/$GITHUB_REPOSITORY/build-cache | |
- name: Push the image to the cache | |
# It's not possible to push packages from fork PRs. | |
if: github.event.pull_request.head.repo.full_name == github.repository | |
run: | | |
docker tag pyaleph-node:${GITHUB_REF##*/} ghcr.io/$GITHUB_REPOSITORY/build-cache | |
docker push ghcr.io/$GITHUB_REPOSITORY/build-cache |