diff --git a/.github/workflows/linter-conan-v2.yml b/.github/workflows/linter-conan-v2.yml index 7a00231462537..0c01856e18ae7 100644 --- a/.github/workflows/linter-conan-v2.yml +++ b/.github/workflows/linter-conan-v2.yml @@ -14,25 +14,32 @@ jobs: name: Test linter changes (v2 migration) runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 with: - fetch-depth: 2 + python-version: ${{ env.PYVER }} - name: Get changed files - uses: tj-actions/changed-files@v20 id: changed_files - with: - files: | - linter/** + shell: python + run: | + import json + import subprocess + import pathlib + import os + + res = subprocess.run(["gh", "api", "/repos/conan-io/conan-center-index/pulls/${{ github.event.pull_request.number }}/files", "--paginate"], capture_output=True, check=True) + files = json.loads(res.stdout) + files = [f["filename"] for f in files] + files = [f for f in files if pathlib.Path(f).is_relative_to('linter/')] + with open(os.getenv("GITHUB_OUTPUT"), "a") as output_file: + output_file.write(f"any_changed={'true' if files else 'false'}\n") + - uses: actions/checkout@v3 + if: steps.changed_files.outputs.any_changed == 'true' - name: Get Conan v1 version id: parse_conan_v1_version if: steps.changed_files.outputs.any_changed == 'true' uses: mikefarah/yq@master with: cmd: yq '.conan.version' '.c3i/config_v1.yml' - - uses: actions/setup-python@v4 - if: steps.changed_files.outputs.any_changed == 'true' - with: - python-version: ${{ env.PYVER }} - name: Install requirements if: steps.changed_files.outputs.any_changed == 'true' run: | @@ -82,25 +89,33 @@ jobs: name: Lint changed conanfile.py (v2 migration) runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 with: - fetch-depth: 2 + python-version: ${{ env.PYVER }} - name: Get changed files id: changed-files - uses: tj-actions/changed-files@v20 - with: - files: | - recipes/*/*/conanfile.py + shell: python + run: | + import json + import subprocess + import pathlib + import os + + res = subprocess.run(["gh", "api", "/repos/conan-io/conan-center-index/pulls/${{ github.event.pull_request.number }}/files", "--paginate"], capture_output=True, check=True) + files = json.loads(res.stdout) + files = [f["filename"] for f in files] + files = [f for f in files if pathlib.Path(f).match('recipes/*/*/conanfile.py')] + with open(os.getenv("GITHUB_OUTPUT"), "a") as output_file: + output_file.write(f"any_changed={'true' if files else 'false'}\n") + output_file.write(f"all_changed_files={' '.join(files)}\n") + - uses: actions/checkout@v3 + if: steps.changed-files.outputs.any_changed == 'true' - name: Get Conan v1 version id: parse_conan_v1_version if: steps.changed-files.outputs.any_changed == 'true' uses: mikefarah/yq@master with: cmd: yq '.conan.version' '.c3i/config_v1.yml' - - uses: actions/setup-python@v4 - if: steps.changed-files.outputs.any_changed == 'true' - with: - python-version: ${{ env.PYVER }} - name: Install dependencies if: steps.changed-files.outputs.any_changed == 'true' run: | @@ -117,25 +132,33 @@ jobs: name: Lint changed test_package/conanfile.py (v2 migration) runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 with: - fetch-depth: 2 + python-version: ${{ env.PYVER }} - name: Get changed files id: changed-files - uses: tj-actions/changed-files@v20 - with: - files: | - recipes/*/*/test_*/conanfile.py + shell: python + run: | + import json + import subprocess + import pathlib + import os + + res = subprocess.run(["gh", "api", "/repos/conan-io/conan-center-index/pulls/${{ github.event.pull_request.number }}/files", "--paginate"], capture_output=True, check=True) + files = json.loads(res.stdout) + files = [f["filename"] for f in files] + files = [f for f in files if pathlib.Path(f).match('recipes/*/*/test_*/conanfile.py')] + with open(os.getenv("GITHUB_OUTPUT"), "a") as output_file: + output_file.write(f"any_changed={'true' if files else 'false'}\n") + output_file.write(f"all_changed_files={' '.join(files)}\n") + - uses: actions/checkout@v3 + if: steps.changed-files.outputs.any_changed == 'true' - name: Get Conan v1 version id: parse_conan_v1_version if: steps.changed-files.outputs.any_changed == 'true' uses: mikefarah/yq@master with: cmd: yq '.conan.version' '.c3i/config_v1.yml' - - uses: actions/setup-python@v4 - if: steps.changed-files.outputs.any_changed == 'true' - with: - python-version: ${{ env.PYVER }} - name: Install dependencies if: steps.changed-files.outputs.any_changed == 'true' run: | diff --git a/.github/workflows/linter-yaml.yml b/.github/workflows/linter-yaml.yml index edc701a2db86d..8190cdcfde861 100644 --- a/.github/workflows/linter-yaml.yml +++ b/.github/workflows/linter-yaml.yml @@ -15,22 +15,29 @@ jobs: name: Test linter changes (YAML files) runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 with: - fetch-depth: 2 - + python-version: ${{ env.PYVER }} - name: Get changed files - uses: tj-actions/changed-files@v20 id: changed_files - with: - files: | - linter/** - - - uses: actions/setup-python@v4 + shell: python + run: | + import json + import subprocess + import pathlib + import os + + res = subprocess.run(["gh", "api", "/repos/conan-io/conan-center-index/pulls/${{ github.event.pull_request.number }}/files", "--paginate"], capture_output=True, check=True) + files = json.loads(res.stdout) + files = [f["filename"] for f in files] + files = [f for f in files if pathlib.Path(f).is_relative_to("linter/")] + with open(os.getenv("GITHUB_OUTPUT"), "a") as output_file: + output_file.write(f"any_changed={'true' if files else 'false'}\n") + output_file.write(f"all_changed_files={' '.join(files)}\n") + - uses: actions/checkout@v3 if: steps.changed_files.outputs.any_changed == 'true' with: - python-version: ${{ env.PYVER }} - + fetch-depth: 2 - name: Install dependencies if: steps.changed_files.outputs.any_changed == 'true' run: pip install yamllint strictyaml argparse @@ -68,10 +75,6 @@ jobs: name: Lint changed files (YAML files) runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 2 - - uses: actions/setup-python@v4 with: python-version: ${{ env.PYVER }} @@ -83,10 +86,21 @@ jobs: - name: Get changed files (config) id: changed_files_config if: always() - uses: tj-actions/changed-files@v20 - with: - files: | - ${{ env.CONFIG_FILES_PATH }} + shell: python + run: | + import json + import subprocess + import pathlib + import os + + res = subprocess.run(["gh", "api", "/repos/conan-io/conan-center-index/pulls/${{ github.event.pull_request.number }}/files", "--paginate"], capture_output=True, check=True) + files = json.loads(res.stdout) + files = [f["filename"] for f in files] + files = [f for f in files if pathlib.Path(f).match('${{ env.CONFIG_FILES_PATH }}')] + with open(os.getenv("GITHUB_OUTPUT"), "a") as output_file: + output_file.write(f"any_changed={'true' if files else 'false'}\n") + output_file.write(f"all_changed_files={' '.join(files)}\n") + - uses: actions/checkout@v3 - name: Run linter (config.yml) if: steps.changed_files_config.outputs.any_changed == 'true' && always() @@ -105,10 +119,19 @@ jobs: - name: Get changed files (conandata) id: changed_files_conandata if: always() - uses: tj-actions/changed-files@v20 - with: - files: | - ${{ env.CONANDATA_FILES_PATH }} + run: | + import json + import subprocess + import pathlib + import os + + res = subprocess.run(["gh", "api", "/repos/conan-io/conan-center-index/pulls/${{ github.event.pull_request.number }}/files", "--paginate"], capture_output=True, check=True) + files = json.loads(res.stdout) + files = [f["filename"] for f in files] + files = [f for f in files if pathlib.Path(f).match('${{ env.CONANDATA_FILES_PATH }}')] + with open(os.getenv("GITHUB_OUTPUT"), "a") as output_file: + output_file.write(f"any_changed={'true' if files else 'false'}\n") + output_file.write(f"all_changed_files={' '.join(files)}\n") - name: Run linter (conandata.yml) if: steps.changed_files_conandata.outputs.any_changed == 'true' && always()