Skip to content

upload packages

upload packages #579

Workflow file for this run

---
name: upload packages
# yamllint disable rule:line-length
# Controls when the action will run.
on: # yamllint disable-line rule:truthy
# schedule test for nightly build
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Note: the defaults are repeated within the 'env' section
# of some of the jobs so any change to the default
# need to be done (at least) twice!
inputs:
download:
type: choice
description: 'download location ( dune | lund ) [dune]'
required: true
default: 'dune'
options:
- dune
- github
- lund
upload:
type: choice
description: 'upload (none | testpypi | pypi) [none]'
required: true
default: 'none'
options:
- none
- pypi
- testpypi
branch:
# note: this should be either 'master' or a tag of the form
# vN where 'N' is a legal python package version
# e.g. N=2.8.0rc1
# otherwise the distributions will not be generated
# and the build will fail
description: 'core tag e.g. (master | v2.8.0) [master]'
required: true
default: 'master'
fembranch:
# note: this should be either 'master' or a tag of the form
# vN where 'N' is a legal python package version
# e.g. N=2.8.0rc1
# otherwise the distributions will not be generated
# and the build will fail
description: 'fem tag e.g. (master | v2.8.0.1) [master]'
required: true
default: 'master'
runTests:
type: boolean
description: run testing scenarios [true]
required: true
default: true
logLevel:
type: choice
description: 'Log level [Warning]'
required: true
default: 'Warning'
options:
- Debug
- Warning
- Info
- error
# needed only for dispatching from other repo
distinct_id:
required: false
description: 'set when dispatching from external repo - leave empty'
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build:
name: build
runs-on: [ubuntu-latest]
env:
DOWNURL: 'https://gitlab.dune-project.org'
RUNTESTS: ${{ !contains(github.event.inputs.runTests, 'false') }}
steps:
- name: echo distinct ID ${{ github.event.inputs.distinct_id }}
if: github.event.inputs.distinct_id != ''
run: echo ${{ github.event.inputs.distinct_id }}
- name: downloadGithub
if: github.event.inputs.download == 'github'
run: echo "DOWNURL=https://github.com/adedner" >> $GITHUB_ENV
- name: downloadLund
if: github.event.inputs.download == 'lund'
run: echo "DOWNURL=https://gitlab.maths.lu.se/dune" >> $GITHUB_ENV
- name: printParameters
run: |
echo "Workflow parameters"
echo "Using github branch : ${GITHUB_REF#refs/heads/}"
echo "Using log level : ${{ github.event.inputs.logLevel }}"
echo "Using download : ${{ env.DOWNURL }}"
echo "Using upload : ${{ github.event.inputs.upload }}"
echo "Using dune-core branch: ${{ github.event.inputs.branch }}"
echo "Using dune-fem branch: ${{ github.event.inputs.fembranch }}"
echo "Run tests: ${{ github.event.inputs.runTests }}"
echo "ref: ${{ github.ref }}"
- name: starting
uses: actions/checkout@v4
- name: Test on dune/dune-testpypi and get the run ID
uses: codex-/return-dispatch@v1
id: return_dispatch
with:
token: ${{ secrets.Dispatch_Secret }}
repo: dune-testpypi
owner: dune-project
ref: ${{ github.ref }}
workflow: testing.yml
workflow_inputs: '{ "logLevel": "${{ github.event.inputs.logLevel }}", "branch": "${{ github.event.inputs.branch }}", "fembranch": "${{ github.event.inputs.fembranch }}", "download": "${{ env.DOWNURL }}", "runTests": "${{ env.RUNTESTS }}" }'
# workflow_timeout_seconds: 120
- name: Await Run ID ${{ steps.return_dispatch.outputs.run_id }}
uses: Codex-/await-remote-run@v1
with:
token: ${{ secrets.Dispatch_Secret }}
repo: dune-testpypi
owner: dune-project
run_id: ${{ steps.return_dispatch.outputs.run_id }}
run_timeout_seconds: 7200
poll_interval_ms: 5000
- name: download artifacts from RUN ID ${{ steps.return_dispatch.outputs.run_id }}
uses: dawidd6/action-download-artifact@v3
with:
github_token: ${{ secrets.Dispatch_Secret }}
repo: dune-project/dune-testpypi
workflow: testing.yml
run_id: ${{ steps.return_dispatch.outputs.run_id }}
workflow_conclusion: success
name: packages
path: dist
if_no_artifact_found: fail
# find the latest - might fail...
# branch: main
# workflow_search: true
- name: upload artifacts
uses: actions/upload-artifact@v4
with:
name: packages
path: dist
# test packages
test:
name: testing tutorial
needs: build
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macOS-latest]
test: [coreA, coreB, extensions]
python: [3.8, 3.11]
runs-on: ${{ matrix.os }}
steps:
- name: starting
uses: actions/checkout@v4
- name: pipPreOrNot
run: |
echo "PIPPRE=--pre" >> $GITHUB_ENV
- name: setup python ${{ matrix.python }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: environmentLog
if: github.event.inputs.logLevel != ''
run: echo "LOGLEVEL=${{ github.event.inputs.logLevel }}" >> $GITHUB_ENV
- name: download artifacts
uses: actions/download-artifact@v4
# if all packages exist on pypi then no artifacts are uploaded so don't fail
continue-on-error: true
with:
name: packages
path: dist
- name: Install dependencies
run: |
curl 'https://raw.githubusercontent.com/dune-project/dune-testpypi/main/ossetup' > ossetup
bash ./ossetup "$RUNNER_OS"
shell: bash
- name: Setup venv
run: |
python3 -m venv dune-env
source dune-env/bin/activate
PYVERS=$(python3 --version)
echo "Selected python version $PYVERS"
pip3 install --upgrade pip
pip3 install matplotlib scipy scikit-build mpi4py pygmsh wheel
if [ "$RUNNER_OS" == "Linux" ]; then
echo "CURRENTLY PETSC4PY IS DISABLED"
# petsc4py is failing at the moment - need to check
# at the moment need to downgrade to 20.0.2 https://gitlab.com/petsc/petsc/-/issues/1369
# PETSC_CONFIGURE_OPTIONS="--download-scalapack --download-suitesparse --download-hypre --download-mumps --download-ml --download-superlu"
# pip3 install -v petsc petsc4py
else
echo "CURRENTLY PETSC4PY IS DISABLED on MACOs due to issues with mpif90 - needs checking"
# while building petsc the following error is produced
# Fortran compiler you provided with --with-fc=/usr/local/bin/mpif90 cannot be found or does not work.
# Cannot compile FC with /usr/local/bin/mpif90.
fi
shell: bash
- name: pip3 install dune modules
run: |
ls dist
source dune-env/bin/activate
pip3 install extract-version
python extractreq.py
cat requirements.txt
pip3 install $PIPPRE -U -v --find-links file://$PWD/dist -r requirements.txt
shell: bash
- name: Setup dune-py
run: |
set +e
source dune-env/bin/activate
pip3 list
python -m dune.fem # tutorial
shell: bash
- name: Run tutorial
run: |
set +e
source dune-env/bin/activate
echo "USING python"
python --version
export DUNEPY_DISABLE_PLOTTING=1
export DUNE_LOG_LEVEL=$LOGLEVEL
export OMP_NUM_THREADS=4
python -c "from dune.fem import threading; print(f'Default number of threads used {threading.use}')"
cd fem_tutorial
python ../run-tutorial.py ${{ matrix.test }}
shell: bash
# https://github.com/marketplace/actions/pypi-publish
upload:
name: uploading
if: ${{ github.event.inputs.upload != 'none' && github.event.inputs.upload != '' }}
needs: test
runs-on: [ubuntu-latest]
# environment: pypi # add this to pypi repos
permissions:
id-token: write
steps:
- name: download artifacts
uses: actions/download-artifact@v4
with:
name: packages
path: dist
- name: remove repository tar.gz since it can't be uploaded
run: rm dist/repos.tar.gz
shell: bash
- name: Publish package to pypi
if: github.event.inputs.upload == 'pypi'
uses: pypa/gh-action-pypi-publish@release/v1
# testpypi not yet updated
- name: Publish package to testpypi
if: github.event.inputs.upload == 'testpypi'
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository-url: https://test.pypi.org/legacy/
## this is needed so long as versioning for
## fem and core packages can differ (i.e. 2.8.0.x) but are uploaded
## in same script.
## Test if required version for core is available on pypi and use
## instead of git?
# skip_existing: true