From 50925c1538759d218d742517bcf01d23792829cb Mon Sep 17 00:00:00 2001 From: Roman Vais Date: Tue, 9 Apr 2024 12:07:09 +0200 Subject: [PATCH 1/3] Add 'zip_lists' filter --- src/yacfg/yacfg.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/yacfg/yacfg.py b/src/yacfg/yacfg.py index 9b1adc0..0a2dde7 100644 --- a/src/yacfg/yacfg.py +++ b/src/yacfg/yacfg.py @@ -136,6 +136,11 @@ def override_value_map_keys(value: Dict[str, Any]) -> Dict[str, Any]: """ return {override_value(key, key): val for key, val in value.items()} + def zip_lists(value: List[Any], pairing: List[Any]) -> List[(Any, Any)]: + if not isinstance(value, List) or not isinstance(pairing, List): + return [] + return zip(value, pairing) + # Pass empty filter for performance if extra_properties_data is not defined (no more conditions) env.filters["overridevalue"] = ( override_value if extra_properties_data else empty_filter @@ -144,6 +149,8 @@ def override_value_map_keys(value: Dict[str, Any]) -> Dict[str, Any]: override_value_list_map_keys if extra_properties_data else empty_filter ) + env.filters["zip_lists"] = zip_lists + template_list = get_main_template_list(env) if output_filter: template_list = filter_template_list(template_list, output_filter) From 3361d94bef018b1ea4935969c6ca5ed562a406e6 Mon Sep 17 00:00:00 2001 From: Roman Vais Date: Thu, 18 Apr 2024 12:17:09 +0200 Subject: [PATCH 2/3] Unify and clean up the github actions. --- .../workflows/main.pull_request.workflow.yaml | 53 +++--------- .github/workflows/main.push.workflow.yaml | 86 +++++-------------- 2 files changed, 34 insertions(+), 105 deletions(-) diff --git a/.github/workflows/main.pull_request.workflow.yaml b/.github/workflows/main.pull_request.workflow.yaml index 3f13150..ebf9ecb 100644 --- a/.github/workflows/main.pull_request.workflow.yaml +++ b/.github/workflows/main.pull_request.workflow.yaml @@ -18,11 +18,10 @@ jobs: fail-fast: false matrix: os: ["Ubuntu"] - python-version: ["3.11", "pypy-3.9"] + python-version: ["3.11", "pypy-3.10", "pypy-3.9"] runs-on: "${{ matrix.os }}-latest" steps: - - uses: "actions/checkout@v4" - name: "Set up Python ${{ matrix.python-version }}" @@ -41,41 +40,15 @@ jobs: python -m pip install --upgrade coverage[toml] tox tox-gh-actions poetry install -# - name: "Configure poetry" -# run: poetry config virtualenvs.in-project true -# -# - name: "Set up cache" -# uses: actions/cache@v2 -# id: cache -# with: -# path: .venv -# key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }} -# -# - name: "Ensure cache is healthy" -# if: steps.cache.outputs.cache-hit == 'true' -# run: timeout 10s poetry run pip --version || rm -rf .venv - - name: "Run tox targets for ${{ matrix.python-version }}" run: tox -# - name: "Get coverage" -# if: "contains(env.USING_COVERAGE, matrix.python-version)" -# run: | -# set -xe -# tox -e coverage-report - -# - name: "Upload coverage to Codecov" -# if: "contains(env.USING_COVERAGE, matrix.python-version)" -# uses: "codecov/codecov-action@v1" -# with: -# fail_ci_if_error: true -# -# - name: "Upload coverage artifacts" -# if: "contains(env.USING_DOCS, matrix.python-version)" -# uses: actions/upload-artifact@v4 -# with: -# name: coverage -# path: .coverage-reports + - name: "Upload docs artifacts" + uses: actions/upload-artifact@v4 + if: "contains(env.USING_DOCS, matrix.python-version)" + with: + name: docs + path: docs/_build/html - name: "Build package" run: | @@ -87,9 +60,9 @@ jobs: name: package-dist-${{ runner.os }}-${{ steps.full-python-version.outputs.python-version }} path: dist/ - - name: "Upload docs artifacts" - uses: actions/upload-artifact@v4 - if: "contains(env.USING_DOCS, matrix.python-version)" - with: - name: docs - path: docs/_build/html + - name: "Run help" + run: "poetry run yacfg --help" + + - name: "Run the test script" + run: ./profile_test.sh + diff --git a/.github/workflows/main.push.workflow.yaml b/.github/workflows/main.push.workflow.yaml index 2f553dc..1025cc7 100644 --- a/.github/workflows/main.push.workflow.yaml +++ b/.github/workflows/main.push.workflow.yaml @@ -9,7 +9,6 @@ on: jobs: Tests: name: "Tests | ${{ matrix.os }} | Python ${{ matrix.python-version }}" - env: USING_COVERAGE: '3.11' USING_DOCS: '3.11' @@ -19,10 +18,10 @@ jobs: fail-fast: false matrix: os: ["Ubuntu", "Windows"] - python-version: ["3.11", "3.10"] + python-version: ["3.11", "pypy-3.10", "pypy-3.9"] runs-on: "${{ matrix.os }}-latest" - steps: + steps: - uses: "actions/checkout@v4" - name: "Set up Python ${{ matrix.python-version }}" @@ -37,60 +36,36 @@ jobs: run: | python -VV python -m site - python -m pip install --upgrade pip setuptools wheel coverage[toml] tox tox-gh-actions + python -m pip install --upgrade pip setuptools wheel + python -m pip install --upgrade coverage[toml] tox tox-gh-actions poetry install -# - name: "Configure poetry" -# run: poetry config virtualenvs.in-project true -# -# - name: "Set up cache" -# uses: actions/cache@v2 -# id: cache -# with: -# path: .venv -# key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }} -# -# - name: "Ensure cache is healthy" -# if: steps.cache.outputs.cache-hit == 'true' -# run: timeout 10s poetry run pip --version || rm -rf .venv - - name: "Run tox targets for ${{ matrix.python-version }}" run: tox -# - name: "Get coverage" -# if: "contains(env.USING_COVERAGE, matrix.python-version)" -# run: | -# set -xe -# tox -e coverage-report - -# - name: "Upload coverage to Codecov" -# if: "contains(env.USING_COVERAGE, matrix.python-version)" -# uses: "codecov/codecov-action@v1" -# with: -# fail_ci_if_error: true - - name: "Upload docs artifacts" if: "contains(env.USING_DOCS, matrix.python-version)" uses: actions/upload-artifact@v4 with: name: docs path: docs/_build/html -# -# - name: "Upload coverage artifacts" -# if: "contains(env.USING_DOCS, matrix.python-version)" -# uses: actions/upload-artifact@v4 -# with: -# name: coverage -# path: .coverage-reports -# -# - name: "Publish package to TestPyPI" -# if: "contains(env.TESTPYPI_PUBLISH, matrix.python-version)" -# uses: pypa/gh-action-pypi-publish@v1.3.1 -# with: -# skip_existing: true -# user: __token__ -# password: ${{ secrets.TESTPYPI_TOKEN }} -# repository_url: https://test.pypi.org/legacy/ + + - name: "Build package" + run: | + poetry build + + - name: "Upload dist artifacts" + uses: actions/upload-artifact@v4 + with: + name: package-dist-${{ runner.os }}-${{ steps.full-python-version.outputs.python-version }} + path: dist/ + + - name: "Run help" + run: "poetry run yacfg --help" + + - name: "Run the test script" + run: ./profile_test.sh + Build: needs: Tests @@ -112,20 +87,6 @@ jobs: - name: "Install poetry" uses: "abatilo/actions-poetry@v3.0.0" -# -# - name: "Configure poetry" -# run: poetry config virtualenvs.in-project true -# -# - name: "Set up cache" -# uses: actions/cache@v2 -# id: cache -# with: -# path: .venv -# key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }} -# -# - name: "Ensure cache is healthy" -# if: steps.cache.outputs.cache-hit == 'true' -# run: timeout 10s poetry run pip --version || rm -rf .venv - name: "Build package" id: build @@ -152,11 +113,6 @@ jobs: with: name: docs path: pages -# -# - uses: actions/download-artifact@master -# with: -# name: coverage -# path: pages/coverage # Push the docs' HTML to github-pages - name: "GitHub Pages action" From 6dd84f6d68733b2d3ef2599925bdc04ed03e98bb Mon Sep 17 00:00:00 2001 From: Roman Vais Date: Thu, 18 Apr 2024 16:01:23 +0200 Subject: [PATCH 3/3] Let profile_test.sh be executable. --- profile_test.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 profile_test.sh diff --git a/profile_test.sh b/profile_test.sh old mode 100644 new mode 100755