Skip to content

Commit

Permalink
github actions: don't use tj-actions/changed-files
Browse files Browse the repository at this point in the history
avoids all its bugs alltogether
eg tj-actions/changed-files#704
  • Loading branch information
ericLemanissier committed Oct 25, 2022
1 parent 58be5b4 commit ac3821e
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 53 deletions.
83 changes: 53 additions & 30 deletions .github/workflows/linter-conan-v2.yml
Expand Up @@ -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: |
Expand Down Expand Up @@ -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: |
Expand All @@ -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: |
Expand Down
69 changes: 46 additions & 23 deletions .github/workflows/linter-yaml.yml
Expand Up @@ -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
Expand Down Expand Up @@ -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 }}
Expand All @@ -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()
Expand All @@ -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()
Expand Down

0 comments on commit ac3821e

Please sign in to comment.