From 37c026268e7161044e0b3ede1f79811c7289d9fa Mon Sep 17 00:00:00 2001 From: jeanluc Date: Sat, 6 Jan 2024 19:23:27 +0100 Subject: [PATCH] Migrate to centralized workflows Also: * Update test reqs to be in sync with official template * Fix unittest opts confdir --- .copier-answers.yml | 3 +- .github/workflows/pr.yml | 17 ++ .github/workflows/tag.yml | 31 +++ .github/workflows/test.yml | 420 ------------------------------------- pyproject.toml | 4 +- tests/unit/conftest.py | 5 + 6 files changed, 57 insertions(+), 423 deletions(-) create mode 100644 .github/workflows/pr.yml create mode 100644 .github/workflows/tag.yml delete mode 100644 .github/workflows/test.yml diff --git a/.copier-answers.yml b/.copier-answers.yml index 66640328..4196e665 100644 --- a/.copier-answers.yml +++ b/.copier-answers.yml @@ -1,6 +1,6 @@ # Autogenerated. Do not edit this by hand, use `copier update`. --- -_commit: 0.2.6 +_commit: 0.2.7 _src_path: https://github.com/lkubb/salt-extension-copier author: jeanluc author_email: lkubb@protonmail.com @@ -21,3 +21,4 @@ ssh_fixtures: false summary: Salt Extension for interacting with Pushover tracker_url: https://github.com/salt-extensions/saltext-pushover/issues url: https://github.com/salt-extensions/saltext-pushover +workflows: org diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml new file mode 100644 index 00000000..16819696 --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,17 @@ +name: Pull Request or Push + +on: + push: + branches: + - 'main' # Run on pushes to main + tags-ignore: + - '*' # Ignore pushes to tags + pull_request: + +jobs: + call_central_workflow: + name: CI + uses: salt-extensions/central-artifacts/.github/workflows/ci.yml@main + permissions: + contents: write + pull-requests: read diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml new file mode 100644 index 00000000..a3bf12d1 --- /dev/null +++ b/.github/workflows/tag.yml @@ -0,0 +1,31 @@ +name: Tagged Releases + +on: + push: + tags: + - "v*" # Only tags starting with "v" for "v1.0.0", etc. + +jobs: + get_tag_version: + runs-on: ubuntu-latest + outputs: + version: ${{ steps.get_version.outputs.version }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Extract tag name + id: get_version + run: echo "::set-output name=version::$(echo ${GITHUB_REF#refs/tags/v})" + + call_central_workflow: + needs: get_tag_version + uses: salt-extensions/central-artifacts/.github/workflows/ci.yml@main + with: + release: true + version: ${{ needs.get_tag_version.outputs.version }} + permissions: + contents: write + id-token: write + pull-requests: read + secrets: inherit diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index fd690b56..00000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,420 +0,0 @@ ---- -name: Testing - -on: [push, pull_request] - -jobs: - Pre-Commit: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: 3.7 - - name: Set Cache Key - run: echo "PY=$(python --version --version | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV - - name: Install System Deps - run: | - sudo apt-get update - sudo apt-get install -y libxml2 libxml2-dev libxslt-dev - - uses: actions/cache@v3 - with: - path: ~/.cache/pre-commit - key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }} - - uses: pre-commit/action@v3.0.0 - - Docs: - runs-on: ubuntu-latest - needs: Pre-Commit - - timeout-minutes: 10 - - steps: - - uses: actions/checkout@v4 - - - name: Set up Python 3.7 For Nox - uses: actions/setup-python@v4 - with: - python-version: 3.7 - - - name: Install Nox - run: | - python -m pip install --upgrade pip - pip install nox - - - name: Install Doc Requirements - run: | - nox --force-color -e docs --install-only - - - name: Build Docs - env: - SKIP_REQUIREMENTS_INSTALL: YES - run: | - nox --force-color -e docs - - Linux: - runs-on: ubuntu-latest - needs: Pre-Commit - - timeout-minutes: 15 - - strategy: - fail-fast: false - max-parallel: 4 - matrix: - include: - - {salt-version: "3005.4", python-version: "3.7"} - - {salt-version: "3005.4", python-version: "3.8"} - - {salt-version: "3005.4", python-version: "3.9"} - - {salt-version: "3005.4", python-version: "3.10"} - - {salt-version: "3006.4", python-version: "3.7"} - - {salt-version: "3006.4", python-version: "3.8"} - - {salt-version: "3006.4", python-version: "3.9"} - - {salt-version: "3006.4", python-version: "3.10"} - - steps: - - uses: actions/checkout@v4 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - - name: Install Nox - run: | - python -m pip install --upgrade pip - pip install nox - - - name: Install Test Requirements - env: - SALT_REQUIREMENT: salt==${{ matrix.salt-version }} - run: | - nox --force-color -e tests-3 --install-only - - - name: Test - env: - SALT_REQUIREMENT: salt==${{ matrix.salt-version }} - SKIP_REQUIREMENTS_INSTALL: YES - run: | - nox --force-color -e tests-3 -- -vv tests/ - - - name: Create CodeCov Flags - if: always() - id: codecov-flags - run: | - echo ::set-output name=flags::$(python -c "import sys; print('{},{},salt_{}'.format('${{ runner.os }}'.replace('-latest', ''), 'py{}{}'.format(*sys.version_info), '_'.join(str(v) for v in '${{ matrix.salt-version }}'.replace('==', '_').split('.'))))") - - - name: Upload Project Code Coverage - if: always() - shell: bash - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - REPORT_FLAGS: ${{ steps.codecov-flags.outputs.flags }},project - REPORT_NAME: ${{ runner.os }}-Py${{ matrix.python-version }}-Salt${{ matrix.salt-version }}-project - REPORT_PATH: artifacts/coverage-project.xml - run: | - if [ ! -f codecov.sh ]; then - n=0 - until [ "$n" -ge 5 ] - do - if curl --max-time 30 -L https://codecov.io/bash --output codecov.sh; then - break - fi - n=$((n+1)) - sleep 15 - done - fi - if [ -f codecov.sh ]; then - n=0 - until [ "$n" -ge 5 ] - do - if bash codecov.sh -R $(pwd) -n "${REPORT_NAME}" -f "${REPORT_PATH}" -F "${REPORT_FLAGS}"; then - break - fi - n=$((n+1)) - sleep 15 - done - fi - - - name: Upload Tests Code Coverage - if: always() - shell: bash - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - REPORT_FLAGS: ${{ steps.codecov-flags.outputs.flags }},tests - REPORT_NAME: ${{ runner.os }}-Py${{ matrix.python-version }}-Salt${{ matrix.salt-version }}-tests - REPORT_PATH: artifacts/coverage-tests.xml - run: | - if [ ! -f codecov.sh ]; then - n=0 - until [ "$n" -ge 5 ] - do - if curl --max-time 30 -L https://codecov.io/bash --output codecov.sh; then - break - fi - n=$((n+1)) - sleep 15 - done - fi - if [ -f codecov.sh ]; then - n=0 - until [ "$n" -ge 5 ] - do - if bash codecov.sh -R $(pwd) -n "${REPORT_NAME}" -f "${REPORT_PATH}" -F "${REPORT_FLAGS}"; then - break - fi - n=$((n+1)) - sleep 15 - done - fi - - - name: Upload Logs - if: always() - uses: actions/upload-artifact@v3 - with: - name: runtests-${{ runner.os }}-py${{ matrix.python-version }}-Salt${{ matrix.salt-version }}.log - path: artifacts/runtests-*.log - - Windows: - runs-on: windows-latest - needs: Pre-Commit - - timeout-minutes: 40 - - strategy: - fail-fast: false - max-parallel: 3 - matrix: - include: - - {salt-version: "3005.4", python-version: "3.7"} - - {salt-version: "3006.4", python-version: "3.7"} - - {salt-version: "3006.4", python-version: "3.8"} - - {salt-version: "3006.4", python-version: "3.9"} - - {salt-version: "3006.4", python-version: "3.10"} - - steps: - - uses: actions/checkout@v4 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - - name: Install Nox - run: | - python -m pip install --upgrade pip - pip install nox - - - name: Install Test Requirements - shell: bash - env: - SALT_REQUIREMENT: salt==${{ matrix.salt-version }} - EXTRA_REQUIREMENTS_INSTALL: Cython - run: | - export PATH="/C/Program Files (x86)/Windows Kits/10/bin/10.0.18362.0/x64;$PATH" - nox --force-color -e tests-3 --install-only - - - name: Test - shell: bash - env: - SALT_REQUIREMENT: salt==${{ matrix.salt-version }} - SKIP_REQUIREMENTS_INSTALL: YES - run: | - export PATH="/C/Program Files (x86)/Windows Kits/10/bin/10.0.18362.0/x64;$PATH" - nox --force-color -e tests-3 -- -vv tests/ - - - name: Create CodeCov Flags - if: always() - id: codecov-flags - run: | - echo ::set-output name=flags::$(python -c "import sys; print('{},{},salt_{}'.format('${{ runner.os }}'.replace('-latest', ''), 'py{}{}'.format(*sys.version_info), '_'.join(str(v) for v in '${{ matrix.salt-version }}'.replace('==', '_').split('.'))))") - - - name: Upload Project Code Coverage - if: always() - shell: bash - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - REPORT_FLAGS: ${{ steps.codecov-flags.outputs.flags }},project - REPORT_NAME: ${{ runner.os }}-Py${{ matrix.python-version }}-Salt${{ matrix.salt-version }}-project - REPORT_PATH: artifacts/coverage-project.xml - run: | - if [ ! -f codecov.sh ]; then - n=0 - until [ "$n" -ge 5 ] - do - if curl --max-time 30 -L https://codecov.io/bash --output codecov.sh; then - break - fi - n=$((n+1)) - sleep 15 - done - fi - if [ -f codecov.sh ]; then - n=0 - until [ "$n" -ge 5 ] - do - if bash codecov.sh -R $(pwd) -n "${REPORT_NAME}" -f "${REPORT_PATH}" -F "${REPORT_FLAGS}"; then - break - fi - n=$((n+1)) - sleep 15 - done - fi - - - name: Upload Tests Code Coverage - if: always() - shell: bash - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - REPORT_FLAGS: ${{ steps.codecov-flags.outputs.flags }},tests - REPORT_NAME: ${{ runner.os }}-Py${{ matrix.python-version }}-Salt${{ matrix.salt-version }}-tests - REPORT_PATH: artifacts/coverage-tests.xml - run: | - if [ ! -f codecov.sh ]; then - n=0 - until [ "$n" -ge 5 ] - do - if curl --max-time 30 -L https://codecov.io/bash --output codecov.sh; then - break - fi - n=$((n+1)) - sleep 15 - done - fi - if [ -f codecov.sh ]; then - n=0 - until [ "$n" -ge 5 ] - do - if bash codecov.sh -R $(pwd) -n "${REPORT_NAME}" -f "${REPORT_PATH}" -F "${REPORT_FLAGS}"; then - break - fi - n=$((n+1)) - sleep 15 - done - fi - - - name: Upload Logs - if: always() - uses: actions/upload-artifact@v3 - with: - name: runtests-${{ runner.os }}-py${{ matrix.python-version }}-Salt${{ matrix.salt-version }}.log - path: artifacts/runtests-*.log - - macOS: - runs-on: macOS-latest - needs: Pre-Commit - - timeout-minutes: 40 - - strategy: - fail-fast: false - max-parallel: 3 - matrix: - include: - - {salt-version: "3005.4", python-version: "3.10"} - - {salt-version: "3006.4", python-version: "3.9"} - - {salt-version: "3006.4", python-version: "3.10"} - - steps: - - uses: actions/checkout@v4 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - - name: Install Nox - run: | - python -m pip install --upgrade pip - pip install nox - - - name: Install Test Requirements - env: - SALT_REQUIREMENT: salt==${{ matrix.salt-version }} - run: | - nox --force-color -e tests-3 --install-only - - - name: Test - env: - SALT_REQUIREMENT: salt==${{ matrix.salt-version }} - SKIP_REQUIREMENTS_INSTALL: YES - run: | - nox --force-color -e tests-3 -- -vv tests/ - - - name: Create CodeCov Flags - if: always() - id: codecov-flags - run: | - echo ::set-output name=flags::$(python -c "import sys; print('{},{},salt_{}'.format('${{ runner.os }}'.replace('-latest', ''), 'py{}{}'.format(*sys.version_info), '_'.join(str(v) for v in '${{ matrix.salt-version }}'.replace('==', '_').split('.'))))") - - - name: Upload Project Code Coverage - if: always() - shell: bash - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - REPORT_FLAGS: ${{ steps.codecov-flags.outputs.flags }},project - REPORT_NAME: ${{ runner.os }}-Py${{ matrix.python-version }}-Salt${{ matrix.salt-version }}-project - REPORT_PATH: artifacts/coverage-project.xml - run: | - if [ ! -f codecov.sh ]; then - n=0 - until [ "$n" -ge 5 ] - do - if curl --max-time 30 -L https://codecov.io/bash --output codecov.sh; then - break - fi - n=$((n+1)) - sleep 15 - done - fi - if [ -f codecov.sh ]; then - n=0 - until [ "$n" -ge 5 ] - do - if bash codecov.sh -R $(pwd) -n "${REPORT_NAME}" -f "${REPORT_PATH}" -F "${REPORT_FLAGS}"; then - break - fi - n=$((n+1)) - sleep 15 - done - fi - - - name: Upload Tests Code Coverage - if: always() - shell: bash - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - REPORT_FLAGS: ${{ steps.codecov-flags.outputs.flags }},tests - REPORT_NAME: ${{ runner.os }}-Py${{ matrix.python-version }}-Salt${{ matrix.salt-version }}-tests - REPORT_PATH: artifacts/coverage-tests.xml - run: | - if [ ! -f codecov.sh ]; then - n=0 - until [ "$n" -ge 5 ] - do - if curl --max-time 30 -L https://codecov.io/bash --output codecov.sh; then - break - fi - n=$((n+1)) - sleep 15 - done - fi - if [ -f codecov.sh ]; then - n=0 - until [ "$n" -ge 5 ] - do - if bash codecov.sh -R $(pwd) -n "${REPORT_NAME}" -f "${REPORT_PATH}" -F "${REPORT_FLAGS}"; then - break - fi - n=$((n+1)) - sleep 15 - done - fi - - - name: Upload Logs - if: always() - uses: actions/upload-artifact@v3 - with: - name: runtests-${{ runner.os }}-py${{ matrix.python-version }}-Salt${{ matrix.salt-version }}.log - path: artifacts/runtests-*.log diff --git a/pyproject.toml b/pyproject.toml index a6ad7fbd..6a2c0070 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -75,8 +75,8 @@ lint = [ "saltpylint", ] tests = [ - "pytest>=6.1.0", - "pytest-salt-factories>=1.0.0rc19", + "pytest>=7.2.0", + "pytest-salt-factories>=1.0.0rc28", ] [project.entry-points."salt.loader"] diff --git a/tests/unit/conftest.py b/tests/unit/conftest.py index 3e3fa4aa..b3b6ceda 100644 --- a/tests/unit/conftest.py +++ b/tests/unit/conftest.py @@ -1,3 +1,5 @@ +import os + import pytest import salt.config @@ -17,6 +19,7 @@ def minion_opts(tmp_path): dirpath.mkdir(parents=True) opts[name] = str(dirpath) opts["log_file"] = "logs/minion.log" + opts["conf_file"] = os.path.join(opts["conf_dir"], "minion") return opts @@ -35,6 +38,7 @@ def master_opts(tmp_path): dirpath.mkdir(parents=True) opts[name] = str(dirpath) opts["log_file"] = "logs/master.log" + opts["conf_file"] = os.path.join(opts["conf_dir"], "master") return opts @@ -54,4 +58,5 @@ def syndic_opts(tmp_path): dirpath.mkdir(parents=True) opts[name] = str(dirpath) opts["log_file"] = "logs/syndic.log" + opts["conf_file"] = os.path.join(opts["conf_dir"], "syndic") return opts