11name : CI
22
3- on :
3+ # Runs on GitHub-hosted runners until a NodeRings self-hosted runner exists.
4+ # To switch, register a runner with the labels "self-hosted" and "noderings"
5+ # (see .github/self-hosted-runner.md) and set the repository variable
6+ # NODERINGS_RUNNER=true. Pull requests from forks always stay on
7+ # GitHub-hosted runners: never run untrusted code on our own machines.
8+ " on " :
49 push :
510 branches : [main]
611 pull_request :
@@ -18,82 +23,149 @@ concurrency:
1823 group : ci-${{ github.ref }}
1924 cancel-in-progress : true
2025
21- jobs :
22- format :
23- runs-on : ubuntu-latest
24- steps :
25- - uses : actions/checkout@v7
26- - uses : actions/setup-python@v7
27- with :
28- python-version : " 3.12"
29- - run : pip install "black==26.5.1" "isort==8.0.1"
30- - run : black --check src tests
31- - run : isort --check-only src tests
26+ env :
27+ PIP_DISABLE_PIP_VERSION_CHECK : " 1"
28+ FORCE_COLOR : " 1"
3229
33- lint :
34- runs-on : ubuntu-latest
30+ jobs :
31+ pre-commit :
32+ name : Pre-commit
33+ runs-on : ${{ (vars.NODERINGS_RUNNER == 'true' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository)) && fromJSON('["self-hosted","noderings"]') || 'ubuntu-latest' }}
34+ timeout-minutes : 30
3535 steps :
36- - uses : actions/checkout@v7
36+ - uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
3737 with :
3838 fetch-depth : 0
39- - uses : actions/setup-python@v7
39+ persist-credentials : false
40+ - uses : actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
4041 with :
4142 python-version : " 3.12"
42- - run : pip install -e ".[lint,tests]"
43- - name : Lint the extension
44- run : pylint --rcfile=.pylintrc src/saltext/noderings
45- - name : Lint the tests
46- run : pylint --rcfile=.pylintrc --disable=redefined-outer-name,unused-argument,import-outside-toplevel tests
43+ - run : python -m pip install pre-commit nox uv
44+ - name : Run all hooks (format, docs stubs, bandit, pylint, actionlint)
45+ run : pre-commit run --all-files --show-diff-on-failure --color=always
4746
4847 unit :
4948 name : Unit (Salt ${{ matrix.salt }}, Python ${{ matrix.python }})
50- runs-on : ubuntu-latest
49+ runs-on : ${{ (vars.NODERINGS_RUNNER == 'true' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository)) && fromJSON('["self-hosted","noderings"]') || 'ubuntu-latest' }}
50+ timeout-minutes : 20
5151 strategy :
5252 fail-fast : false
5353 matrix :
5454 include :
55- - {salt: "3006.*", python: "3.11"}
56- - {salt: "3008.*", python: "3.11"}
57- - {salt: "3008.*", python: "3.12"}
55+ - {salt: "3006", python: "3.11"}
56+ - {salt: "3007", python: "3.12"}
57+ - {salt: "3008", python: "3.12"}
58+ - {salt: "3008", python: "3.13"}
5859 steps :
59- - uses : actions/checkout@v7
60+ - uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
6061 with :
6162 fetch-depth : 0
62- - uses : actions/setup-python@v7
63+ persist-credentials : false
64+ - uses : actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
6365 with :
6466 python-version : ${{ matrix.python }}
65- - run : pip install "salt==${{ matrix.salt }}" -e ".[tests]"
66- - run : pytest -ra tests/unit
67+ - run : python -m pip install nox uv
68+ - name : Unit tests (nox session from the copier template)
69+ env :
70+ SALT_REQUIREMENT : salt~=${{ matrix.salt }}.0
71+ run : nox -e "tests-${{ matrix.python }}" -- tests/unit
6772
6873 docs :
69- runs-on : ubuntu-latest
74+ name : Docs
75+ runs-on : ${{ (vars.NODERINGS_RUNNER == 'true' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository)) && fromJSON('["self-hosted","noderings"]') || 'ubuntu-latest' }}
76+ timeout-minutes : 20
7077 steps :
71- - uses : actions/checkout@v7
78+ - uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
7279 with :
7380 fetch-depth : 0
74- - uses : actions/setup-python@v7
81+ persist-credentials : false
82+ - uses : actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
7583 with :
7684 python-version : " 3.12"
77- - run : pip install -e ".[docs]"
78- - run : sphinx-build -W -b html docs docs/_build/html
85+ - name : Check system packages (make, enchant for the spelling extension)
86+ run : |
87+ missing=()
88+ command -v make >/dev/null || missing+=(make)
89+ ldconfig -p | grep -q libenchant-2 || missing+=(libenchant-2-2)
90+ if [ "${#missing[@]}" -gt 0 ]; then
91+ sudo apt-get update -qq && sudo apt-get install -y -qq "${missing[@]}"
92+ fi
93+ - run : python -m pip install nox uv
94+ - name : Build the docs (linkcheck, coverage, HTML; warnings fail)
95+ run : nox -e docs
96+
97+ package :
98+ name : Package
99+ runs-on : ${{ (vars.NODERINGS_RUNNER == 'true' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository)) && fromJSON('["self-hosted","noderings"]') || 'ubuntu-latest' }}
100+ timeout-minutes : 15
101+ steps :
102+ - uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
103+ with :
104+ fetch-depth : 0
105+ persist-credentials : false
106+ - uses : actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
107+ with :
108+ python-version : " 3.12"
109+ - run : python -m pip install build twine
110+ - run : python -m build
111+ - run : python -m twine check --strict dist/*
112+ - name : Install the wheel and check that Salt loads the extension
113+ run : |
114+ python -m venv /tmp/wheel-venv
115+ /tmp/wheel-venv/bin/pip install -q dist/*.whl
116+ /tmp/wheel-venv/bin/python - <<'PY'
117+ from importlib.metadata import entry_points
118+ eps = [ep for ep in entry_points(group="salt.loader") if ep.name == "saltext.noderings"]
119+ assert eps and eps[0].value == "saltext.noderings", eps
120+ import saltext.noderings.clouds.noderings_mod
121+ import saltext.noderings.modules.noderings_mod
122+ import saltext.noderings.states.noderings_mod
123+ print("entry point and modules OK")
124+ PY
125+ mkdir -p /tmp/salt-root
126+ printf 'root_dir: /tmp/salt-root\nfile_client: local\nuser: %s\n' "$(id -un)" > /tmp/salt-root/minion
127+ /tmp/wheel-venv/bin/salt-call -c /tmp/salt-root --local --out=json sys.list_functions noderings | grep -q '"noderings.list_regions"'
128+ /tmp/wheel-venv/bin/salt-call -c /tmp/salt-root --local --out=json sys.list_state_functions noderings | grep -q '"noderings.vm_present"'
79129
80130 live :
81131 name : Live tests (NodeRings API)
82132 needs : [unit]
83133 # Only where the secret exists; forks and outside pull requests skip.
84134 if : github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
85- runs-on : ubuntu-latest
135+ runs-on : ${{ vars.NODERINGS_RUNNER == 'true' && fromJSON('["self-hosted","noderings"]') || 'ubuntu-latest' }}
136+ timeout-minutes : 45
86137 env :
87138 NODERINGS_TOKEN : ${{ secrets.NODERINGS_TOKEN }}
88139 NODERINGS_TEST_BILLED : ${{ inputs.billed && '1' || '' }}
89140 steps :
90- - uses : actions/checkout@v7
141+ - uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
91142 with :
92143 fetch-depth : 0
93- - uses : actions/setup-python@v7
144+ persist-credentials : false
145+ - uses : actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
94146 with :
95147 python-version : " 3.12"
96- - run : pip install "salt== 3008.* " -e ".[tests]"
148+ - run : python -m pip install "salt~= 3008.0 " -e ".[tests]"
97149 - name : Functional and integration tests
98150 if : env.NODERINGS_TOKEN != ''
99151 run : pytest -ra tests/functional tests/integration
152+ - name : Note the skip
153+ if : env.NODERINGS_TOKEN == ''
154+ run : echo "::notice title=Live tests skipped::Add the repository secret NODERINGS_TOKEN (a service account token for a test organization) to run them."
155+
156+ result :
157+ name : CI result
158+ # The one required status check: it fails if any job above failed.
159+ if : always()
160+ needs : [pre-commit, unit, docs, package, live]
161+ runs-on : ubuntu-latest
162+ timeout-minutes : 5
163+ steps :
164+ - name : Check the job results
165+ env :
166+ RESULTS : ${{ join(needs.*.result, ' ') }}
167+ run : |
168+ echo "Job results: $RESULTS"
169+ for r in $RESULTS; do
170+ case "$r" in success|skipped) ;; *) exit 1 ;; esac
171+ done
0 commit comments