-
Notifications
You must be signed in to change notification settings - Fork 2
116 lines (99 loc) · 4.32 KB
/
debug.yml
File metadata and controls
116 lines (99 loc) · 4.32 KB
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
# This workflow will run the Python and Bash alias tests
#
# Notes:
# - This is used for debugging when running the workflow locally via Nektos/Act:
# WORKFLOW_FILE=debug.yml local-workflow.sh ...
# Specifically, it runs with detailed debugging (i.e., DEBUG_LEVEL=5).
# - This leads to the following type of invocation:
# act --container-architecture linux/amd64 --pull="false" -P "ubuntu-latest=local/test-act" -W ./.github/workflows/debug.yml
# - Based initially on tests.yml from Python mezcla package.
# - Requires special permission for Github workflows.
# - For more information see following:
# https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
# - Based initially on version from https://github.com/LimaBD/batspp.
# - Running Github Actions with Docker: https://stackoverflow.com/a/64373702
# - Docker documentation:
# https://docs.docker.com/engine/reference/commandline/cli/
# https://docs.docker.com/storage/bind-mounts
#
# Warning:
# - *** Changes need to be synchronized in 3 places: Dockerfile, local-workflow.sh, and .github/workflow/*.yml!
# - The environment overrides are not working (e.g., DEBUG_LEVEL and TEST_REGEX);
# instead specify them in ../../_temp-user-docker.env
#
name: debug-Tests
on: [push, pull_request]
jobs:
build:
name: Build and Run Tests via Runner
# skip during local actions testing (see https://github.com/nektos/act#skipping-jobs)
if: ${{ !github.event.act }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04]
## TODO: os: [ubuntu-20.04, ubuntu-latest]
python-version: ["3.9"]
## TODO: python-version: ["3.8", "3.9", "3.10"]
## TEST: alternative environment spec for TEST_REGEX override
## See https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
## env:
## TEST_REGEX: dummy-test
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Configure Environment
## TODO2: clarify why used
## See https://stackoverflow.com/questions/57968497/how-do-i-set-an-env-var-with-a-bash-expression-in-github-actions
run: |
echo "PATH=$PATH" >> "$GITHUB_ENV"
echo "PYTHONPATH=$PYTHONPATH:/usr/local/lib/python3.9/dist-packages" >> "$GITHUB_ENV"
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Cache Python Dependencies
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-${{ matrix.python-version }}-
${{ runner.os }}-pip-
- name: Install Dependencies
run: |
pip install --verbose --requirement requirements.txt
- name: Run Python Tests under Runner
run: |
PYTHONPATH="$PWD:$PWD/tests:$PYTHONPATH" ./tests/run_tests.bash
build-and-test-docker:
name: Build and Run Tests via Docker
# include unless skip-docker set (see skip-docker.json)
if: ${{ !github.event.skip-docker }}
runs-on: [ubuntu-22.04]
## TEST:
## NOTE: following is for docker images on the hub
## container:
## image: shell-scripts-dev
## options: --user=root
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Build docker image
run: |
docker build --tag shell-scripts-dev -f- . <Dockerfile
- name: Run tests
run: |
# Note: command format: docker run [OPTIONS] IMAGE [COMMAND] [ARG...];
# The environment file normally has no entries (i.e., just comments).
docker run --env "DEBUG_LEVEL=5" --env-file _temp-user-docker.env --rm --mount type=bind,source="$(pwd)",target=/home/shell-scripts shell-scripts-dev
##
## TEST
## env:
## DEBUG_LEVEL: 5
## ## TODO2: fix me!
## # Note: to test a subset of notebook, define a regex pattern
## # ex: TEST_REGEX: "(README|testing-tips)"
## ## TODO: TEST_REGEX: pattern
## DUMMY_VAR: 1