diff --git a/.github/workflows/all-lints.yml b/.github/workflows/all-lints.yml index 4b90a36..de59ecf 100644 --- a/.github/workflows/all-lints.yml +++ b/.github/workflows/all-lints.yml @@ -8,11 +8,23 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, macos-latest, windows-latest] - python-version: ['3.6', '3.7', '3.8', '3.9', '3.10'] + os: [ubuntu-latest, macos-13, macos-latest, windows-latest] + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] + exclude: + - os: macos-latest + python-version: 3.8 + - os: macos-latest + python-version: 3.9 + - os: macos-latest + python-version: 3.10 + - os: macos-13 + python-version: 3.11 + - os: macos-13 + python-version: 3.12 + steps: - - uses: actions/checkout@v1 - - uses: marian-code/python-lint-annotate@master + - uses: actions/checkout@v4 + - uses: ./ with: python-root-list: "./tests/*.py ./tests/subtest/*.py" use-black: true diff --git a/.github/workflows/test-python-install.yml b/.github/workflows/test-python-install.yml new file mode 100644 index 0000000..038dcd5 --- /dev/null +++ b/.github/workflows/test-python-install.yml @@ -0,0 +1,55 @@ +on: + push: + pull_request: +name: Check python installation +jobs: + pythoninstall: + name: Test Python install + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest] + python-version: ['3.11'] + use-external-python: [true, false] + env: + python-test-package: python-dummy + steps: + - uses: actions/checkout@v4 + + - name: Install Python if required + if: ${{ matrix.use-external-python }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install a test dependency if external Python is used + if: ${{ matrix.use-external-python }} + run: + pip install ${{ env.python-test-package }} + + - name: Test Action usage + uses: ./ + with: + python-root-list: "./tests/*.py ./tests/subtest/*.py" + use-black: true + use-isort: true + use-mypy: true + use-pycodestyle: true + use-pydocstyle: true + extra-pycodestyle-options: "--max-line-length=88" + use-pylint: false + use-flake8: false + use-vulture: true + python-version: ${{ matrix.python-version }} + use-external-python: ${{ matrix.use-external-python }} + + - name: Check if test dependency exists after execution + run: | + pip freeze > all-deps.txt + should_appear=$( if [[ "${{ matrix.use-external-python }}" == "true" ]]; then echo 0; else echo 1; fi ) + line_exists=$( grep -qF "${{ env.python-test-package }}" "all-deps.txt"; echo $? ) + echo "test package should be installed: ${{ matrix.use-external-python }}" + echo "test package is present (0 = present): ${line_exists}" + cat all-deps.txt + test "${should_appear}" == "${line_exists}" + diff --git a/README.md b/README.md index f1b3a49..34e8534 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,8 @@ selected linters. - Zero configuration based: Add a single line in your CI and done! - GitHub Annotations on PR: Highlights issues inline on the PR diff. - Most of the popular community trusted linters in one place. +- Allows to use either a new or existing Python version using `use-external-python`. +See [this example](examples/actions-use_external_python.yml). ## Linters supported @@ -30,23 +32,23 @@ Basic: ```yml steps: - - uses: actions/checkout@v1 - - uses: marian-code/python-lint-annotate@v3 + - uses: actions/checkout@v4 + - uses: marian-code/python-lint-annotate@v4 ``` Options: ```yml steps: - - uses: actions/checkout@v1 - - uses: marian-code/python-lint-annotate@v3 + - uses: actions/checkout@v4 + - uses: marian-code/python-lint-annotate@v4 with: python-root-list: "src/ tests/*" # accepts wildcards use-pycodestyle: false use-mypy: false use-vulture: true extra-pylint-options: "--output-format="colorized" - python-version: "3.7" + python-version: "3.8" ``` ### Examples @@ -54,28 +56,17 @@ steps: ## Details -Uses `actions/setup-python@v2`. Only python `3.6` - `3.10` version are tested since -they are by far most common now. Other python `3.x` versions should also work. +Uses `actions/setup-python@v5`. Only python `3.8` - `3.12` versions are tested. +Python `3.x` versions prior to `3.8` are not tested since they are EOL now. Any python `2.x` versions are unsupported! You can lint on Linux, Windows and MacOS. -The lintner versions are: - -```bash -pycodestyle==2.8.0 -pydocstyle==6.1.1 -pylint==2.12.1 -mypy==0.910 -black==21.11b1 -flake8==4.0.1 -vulture==2.3 -isort==5.10.1 -``` +The linter versions are defined in [requirements.txt](requirements.txt). ## IMPORTANT - test environment -The python version is set by `actions/setup-python@v2` using composite actions. This +The python version is set by `actions/setup-python@v5` using composite actions. This means that the the action will change python you might have previously set with -`actions/setup-python@v2`. There are two ways to circumvent this. +`actions/setup-python@v5`. There are two ways to circumvent this. - Keep the lintnig action separated from others - Use it at the and of your workflow when the change in python version will not @@ -93,14 +84,14 @@ jobs: name: Lint Python runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 - - uses: actions/setup-python@v2 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: 3.9 - run: | python --version # this will output 3.9 now run tests or other things using python ... - - uses: marian-code/python-lint-annotate@v3 + - uses: marian-code/python-lint-annotate@v4 with: python-root-list: "./tests/*.py" use-black: true @@ -112,9 +103,9 @@ jobs: use-pylint: false use-flake8: false use-vulture: true - python-version: "3.7" + python-version: "3.8" - run: | - python --version # this will output 3.7 now !!! + python --version # this will output 3.8 now !!! ``` ## License diff --git a/action.yml b/action.yml index 5ec2538..746853d 100644 --- a/action.yml +++ b/action.yml @@ -76,12 +76,18 @@ inputs: description: "Set desired python version with this keyword" required: false default: "3.8" + use-external-python: + description: "false (default): Install a new Python for this action; true: use the python installation in the previous steps" + type: boolean + required: false + default: false runs: using: "composite" steps: - name: Setup python - uses: actions/setup-python@v2 + if: ${{ ! inputs.use-external-python }} + uses: actions/setup-python@v5 with: python-version: ${{ inputs.python-version }} architecture: x64 @@ -93,13 +99,13 @@ runs: - name: Windows install dependencies if: ${{ runner.os == 'Windows' }} run: | - pip install -r ${{ github.action_path }}\requirements.txt + pip install -r ${{ github.action_path }}\requirements.txt --ignore-installed echo "path_sep=" >> $GITHUB_ENV shell: pwsh - name: Posix install dependencies if: ${{ runner.os != 'Windows' }} - run: pip install -r ${{ github.action_path }}/requirements.txt + run: pip install -r ${{ github.action_path }}/requirements.txt --ignore-installed shell: bash - name: Lint on Windows diff --git a/examples/actions-only_changed_files.yml b/examples/actions-only_changed_files.yml index 02209e4..3bb23bd 100644 --- a/examples/actions-only_changed_files.yml +++ b/examples/actions-only_changed_files.yml @@ -8,11 +8,11 @@ jobs: name: Lint steps: - name: Check out source repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 # This is necessary to get the commits - name: Set up Python environment - uses: actions/setup-python@v3 + uses: actions/setup-python@v5 with: python-version: "3.8" - name: Get changed python files between base and head diff --git a/requirements.txt b/requirements.txt index 73b61ff..95890b8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,8 @@ -black==21.11b1 -flake8==4.0.1 -isort==5.10.1 -mypy~=0.961 -pycodestyle==2.8.0 -pydocstyle==6.1.1 -pylint==2.12.1 -vulture==2.3 \ No newline at end of file +black==24.3.0 +flake8==7.0.0 +isort==5.13.2 +mypy~=1.9.0 +pycodestyle==2.11.1 +pydocstyle==6.3.0 +pylint==3.1.0 +vulture==2.11