-
Notifications
You must be signed in to change notification settings - Fork 0
136 lines (107 loc) · 4.44 KB
/
pull_request.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
name: Pull Request
on:
pull_request:
types: [opened, synchronize, reopened]
# These are needed because secrets can not be used in 'if' expressions
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
TEST_PYPI_TOKEN: ${{ secrets.TEST_PYPI_TOKEN }}
RTD_WEBHOOK_URL: ${{ secrets.RTD_WEBHOOK_URL }}
RTD_WEBHOOK_TOKEN: ${{ secrets.RTD_WEBHOOK_TOKEN }}
jobs:
# Useful for workflow debugging
# printJob:
# name: Print event
# runs-on: ubuntu-latest
# steps:
# - name: Dump GitHub context
# env:
# GITHUB_CONTEXT: ${{ toJson(github) }}
# run: |
# echo "$GITHUB_CONTEXT"
check_configuration:
name: Check for service configuration secrets
runs-on: ubuntu-latest
steps:
# Report on which services are configured
- name: Read the Docs URL
if: "!(env.RTD_WEBHOOK_URL)"
run: echo "::warning title=RTD_WEBHOOK_URL not set::Read the Docs functionality not enabled. Add RTD_WEBHOOK_URL to your repo secrets if you want it enabled."
- name: Read the Docs Token
if: "!(env.RTD_WEBHOOK_TOKEN)"
run: echo "::warning title=RTD_WEBHOOK_TOKEN not set::Read the Docs functionality not enabled. Add RTD_WEBHOOK_TOKEN to your repo secrets if you want it enabled."
- name: test.PyPI Token
if: "!(env.TEST_PYPI_TOKEN)"
run: echo "::warning title=TEST_PYPI_TOKEN not Set::PyPI functionality not enabled. Add PYPI_TOKEN to your repo secrets if you want it enabled."
- name: test.PyPI Token
if: "!(env.TEST_PYPI_TOKEN)"
run: echo "::warning title=TEST_PYPI_TOKEN not Set::test.PyPI functionality not enabled. Add TEST_PYPI_TOKEN to your repo secrets if you want it enabled."
run_tests:
name: Run all build and unit tests
runs-on: ubuntu-latest
steps:
# Clone the base template
- name: Clone base template
uses: actions/checkout@v3
with:
repository: 'ADACS-Australia/adacs_template_python_base'
path: __adacs_template_python_base
# Set the path where the base template will be stored and move it there
- name: Set temporary path
run: echo "TEMP_DIR=$(mktemp -d)" >> $GITHUB_ENV
- name: Move base template
run: mv __adacs_template_python_base $TEMP_DIR
- name: Set path to new base template location
run: echo "BASE_TEMPLATE_PATH=$(echo $TEMP_DIR/__adacs_template_python_base )" >> $GITHUB_ENV
# Set-up dependencies
- name: Check-out repo
uses: actions/checkout@v3
with:
fetch-depth: 0 # Needed for tags to be fetched; see https://github.com/actions/checkout/issues/290
# Uncomment if you need mpi
# - name: Set-up MPI
# uses: mpi4py/setup-mpi@v1
# Uncomment if you need Cuda
# - name: Set-up Cuda Toolkit
# run: sudo apt-get install nvidia-cuda-toolkit nvidia-cuda-toolkit-gcc
- name: Set-up Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Set-up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: 'poetry'
# Configure project
- name: Set project version
run: poetry version $(git describe --tags --abbrev=0)
# Install the project (we need some of the tools installed here for liniting etc)
- name: Install the project
run: poetry install --no-interaction
# Enforce code formating standards
# note: --config is needed to prevent ruff from using a version elsewhere in the project.
# This is important for template projects, for example.
- name: Enforce linting
run: poetry run ruff check --config pyproject.toml .
- name: Enforce formating
run: poetry run black .
# Make sure the Poetry project is properly maintained
- name: Enforce maintainance of Poetry project
run: |
poetry check
poetry lock --check
# Set-up some dummy git credentials so the tests (which use git) will run
- name: Set-up git credentials
run: |
git config --global user.email "git@user.org"
git config --global user.name "Git, User"
# Run tests
- name: Generate build
run: poetry build
- name: Code tests
run: poetry run pytest
- name: Documentation build test
run: poetry run make -f docs/Makefile docs