Devops: Fix the CD workflow #322
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
name: ci | |
on: [push, pull_request] | |
jobs: | |
pre-commit: | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python 3.9 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.9 | |
- name: Install python dependencies | |
run: | | |
pip install .[pre_commit,testing] | |
pip freeze | |
- name: Run pre-commit | |
run: | |
pre-commit run --all-files || ( git status --short ; git diff ; exit 1 ) | |
ubuntu-apt: | |
# ubuntu using postgresql installed via apt (+ pgtest) | |
timeout-minutes: 5 | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: [3.8, 3.11] | |
os: [ubuntu-20.04, ubuntu-22.04] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install system dependencies | |
run: sudo apt update && sudo apt install postgresql && sudo service postgresql restart | |
- name: Install pgsu | |
run: | | |
pip install -e .[testing] | |
pip freeze | |
- name: Run test suite | |
run: pytest --cov-report xml -sv | |
- name: Upload coverage report | |
if: github.repository == 'aiidateam/pgsu' | |
uses: codecov/codecov-action@v4 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
name: ubuntu-apt | |
file: ./coverage.xml | |
fail_ci_if_error: true | |
ubuntu-postgres-action: | |
# ubuntu using postgres docker container (custom action) | |
runs-on: ubuntu-22.04 | |
timeout-minutes: 5 | |
strategy: | |
matrix: | |
python-version: [3.9] | |
postgres-pw: ["testpw"] | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: CasperWA/postgresql-action@v1.2 | |
with: | |
postgresql version: '10' | |
postgresql db: test_db | |
postgresql user: postgres | |
postgresql password: ${{ matrix.postgres-pw}} | |
#postgresql auth: trust | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install pgsu | |
run: | | |
pip install -e .[testing] | |
pip freeze | |
- name: Run test suite | |
env: | |
PGSU_TEST_PASSWORD: ${{ matrix.postgres-pw}} | |
run: pytest --cov-report xml -sv | |
- name: Upload coverage report | |
if: github.repository == 'aiidateam/pgsu' | |
uses: codecov/codecov-action@v4 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
name: ubuntu-apt | |
file: ./coverage.xml | |
fail_ci_if_error: true | |
ubuntu-postgres-service: | |
# ubuntu using postgres docker container (service provided by github actions) | |
runs-on: ubuntu-22.04 | |
timeout-minutes: 5 | |
strategy: | |
matrix: | |
python-version: [3.9] | |
postgres-pw: ["testpw"] | |
services: | |
postgres: | |
image: postgres:10.8 | |
env: | |
POSTRGRES_USER: postgres | |
POSTGRES_PASSWORD: ${{ matrix.postgres-pw}} | |
POSTGRES_DB: test_db | |
ports: | |
# will assign a random free host port | |
- 5432/tcp | |
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install pgsu | |
run: | | |
pip install -e .[testing] | |
pip freeze | |
- name: Run test suite | |
env: | |
PGSU_TEST_PASSWORD: ${{ matrix.postgres-pw}} | |
PGSU_TEST_PORT: ${{ job.services.postgres.ports[5432] }} | |
run: pytest --cov-report xml -sv | |
- name: Upload coverage report | |
if: github.repository == 'aiidateam/pgsu' | |
uses: codecov/codecov-action@v4 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
name: ubuntu-postgres-service | |
file: ./coverage.xml | |
fail_ci_if_error: true | |
# macos-brew: | |
# # macos using postgres installed via homebrew (+pgtest) | |
# | |
# runs-on: macos-12 | |
# timeout-minutes: 5 | |
# | |
# strategy: | |
# matrix: | |
# python-version: [3.8] | |
# | |
# steps: | |
# - uses: actions/checkout@v3 | |
# | |
# - name: Set up Python ${{ matrix.python-version }} | |
# uses: actions/setup-python@v4 | |
# with: | |
# python-version: ${{ matrix.python-version }} | |
# | |
# - name: Install system dependencies | |
# run: | | |
# brew install postgresql || brew link --overwrite postgresql | |
# | |
# - name: Install pgsu | |
# run: | | |
# pip install -e .[testing] | |
# pip freeze | |
# | |
# # note: I tested this locally with *only* the homebrew postgres server running and it worked. | |
# # no idea why this does not work on github actions | |
# # Edit: It seems homebrew postgresql does not create the postgres user automatically. | |
# - name: Run test suite | |
# run: | | |
# brew services start postgresql | |
# brew services list | |
# pytest | |
multi-conda: | |
# windows and macos with postgres installed via conda (+pgtest) | |
runs-on: ${{ matrix.os }} | |
timeout-minutes: 5 | |
strategy: | |
matrix: | |
python-version: [3.8] | |
os: ['macos-12', 'windows-2022'] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- uses: conda-incubator/setup-miniconda@v3 | |
with: | |
python-version: ${{ matrix.python-version }} | |
run-post: false # https://github.com/conda-incubator/setup-miniconda/issues/280 | |
- name: Install system dependencies | |
shell: bash -l {0} | |
run: | | |
conda install -y -c anaconda postgresql | |
initdb -D test_db | |
pg_ctl -D test_db -o "-d 5" start # start with debugging | |
- name: Install pgsu | |
run: | | |
pip install -e .[testing] | |
pip freeze | |
- name: Run test suite | |
run: pytest --cov-report xml -sv | |
- name: Upload coverage report | |
if: github.repository == 'aiidateam/pgsu' | |
uses: codecov/codecov-action@v4 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
name: "${{ matrix.os }}-conda" | |
file: ./coverage.xml | |
fail_ci_if_error: true |