File tree Expand file tree Collapse file tree 5 files changed +98
-51
lines changed
Expand file tree Collapse file tree 5 files changed +98
-51
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ name : Run Tests
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+ pull_request :
8+ branches :
9+ - main
10+
11+ jobs :
12+ run-tests-in-container :
13+ runs-on : ubuntu-latest
14+
15+ steps :
16+ - name : Checkout repository
17+ uses : actions/checkout@v4
18+ with :
19+ submodules : true
20+
21+ - name : Build container image with podman
22+ run : |
23+ podman build \
24+ -f Containerfile \
25+ -t flatpak-indexer:latest \
26+ --build-arg=FLATPAK_INDEXER_UPDATE_TEST_DATA=1 \
27+ .
28+
29+ source-code-checks :
30+ runs-on : ubuntu-latest
31+
32+ steps :
33+ - name : Checkout repository
34+ uses : actions/checkout@v4
35+
36+ - name : Set up Python 3.12
37+ uses : actions/setup-python@v5
38+ with :
39+ python-version : ' 3.12'
40+
41+ - name : Install dependencies
42+ run : |
43+ sudo apt-get update
44+ sudo apt-get install python3.12-dev gcc libkrb5-dev
45+ pip install uv
46+ uv sync
47+
48+ - name : Check source code
49+ run : |
50+ uv run tools/test.sh --ruff-format --ruff-check
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ COPY --from=tar-diff-builder /opt/app-root/bin/tar-diff /opt/app-root/bin/
3737COPY --from=builder /opt/app-root /opt/app-root
3838
3939# Run tests
40- RUN $APP_ROOT/src/tools/test.sh
40+ RUN $APP_ROOT/src/tools/test.sh --pytest
4141
4242# Set the default command for the resulting image
4343CMD /usr/libexec/s2i/run
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ dependencies = [
1919 " requests" ,
2020 " PyYAML" ,
2121 " version_utils>=0.3.2" ,
22- # Dev requirements - listed in main dependencies to make the image
22+ # Test requirements - listed in main dependencies to make the image
2323 # self-contained for testing.
2424 # 2.22.0 contains an accidental incompatibility with python < 3.11,
2525 # fixed in git.
@@ -29,25 +29,16 @@ dependencies = [
2929 " pytest" ,
3030 " pytest-cov" ,
3131 " pytest-socket" ,
32- " ruff" ,
3332 " responses" ,
3433 " www-authenticate" ,
3534]
3635
3736[project .scripts ]
3837flatpak-indexer = " flatpak_indexer.cli:cli"
3938
40- [project .optional-dependencies ]
41- # Alternative: install only dev dependencies separately
39+ [dependency-groups ]
4240dev = [
43- " fakeredis!=2.22.0" ,
44- " graphql-core" ,
45- " iso8601" ,
46- " pytest" ,
47- " pytest-cov" ,
48- " pytest-socket" ,
49- " responses" ,
50- " www-authenticate" ,
41+ " ruff" ,
5142]
5243
5344[tool .setuptools .packages .find ]
Original file line number Diff line number Diff line change 11#! /bin/bash
22
3- set +e -x
4-
53# These are set to build-time specific location when building the Red Hat-internal
64# image; unset them to avoid breaking things at runtime.
75unset REQUESTS_CA_BUNDLE
86unset GIT_SSL_CAINFO
97
10- pytest --cov-fail-under=100 " $@ "
8+ modules=()
9+ pytest_args=()
10+ all=true
11+ failed=" "
12+
13+ for arg in " $@ " ; do
14+ case $arg in
15+ --pytest|--ruff-check|--ruff-format|--pyright)
16+ modules+=(" ${arg# --} " )
17+ all=false
18+ ;;
19+ * )
20+ modules+=(pytest)
21+ pytest_args+=(" $arg " )
22+ all=false
23+ ;;
24+ esac
25+ done
26+
27+ if $all ; then
28+ modules=(pytest pyright ruff-check ruff-format)
29+ fi
1130
12- [ $? == 0 ] || failed=" $failed pytest"
13- ruff format --check flatpak_indexer tests tools
14- [ $? == 0 ] || failed=" $failed ruff-format"
15- ruff check flatpak_indexer tests tools
16- [ $? == 0 ] || failed=" $failed ruff-check"
31+ if [[ " ${# pytest_args[@]} " = 0 ]] ; then
32+ pytest_args=(--cov-fail-under=100)
33+ fi
34+
35+ run () {
36+ module=$1
37+ shift
38+ if [[ " ${modules[*]} " =~ " $module " ]] ; then
39+ if [[ -t 1 ]] ; then
40+ echo -e " \e[33m\e[1mRUNNING\e[0m: $* "
41+ else
42+ echo " RUNNING: $* "
43+ fi
44+ " $@ "
45+ [[ $? -eq 0 ]] || failed=" $failed $module "
46+ fi
47+ }
1748
18- set -e +x
49+ run pytest pytest " ${pytest_args[@]} "
50+ run ruff-format ruff format --check flatpak_indexer tests tools
51+ run ruff-check ruff check flatpak_indexer tests tools
1952
20- if [ " $failed " != " " ] ; then
53+ if [[ " $failed " != " " ] ] ; then
2154 if [[ -t 1 ]] ; then
22- echo -e " \e[31m\e[1mFAILED: \e[0m$failed "
55+ echo -e " \e[31m\e[1mFAILED\e[0m: $failed "
2356 else
2457 echo -e " FAILED:$failed "
2558 fi
You can’t perform that action at this time.
0 commit comments