Skip to content

Commit

Permalink
sanity-checks: Make it run locally (#122)
Browse files Browse the repository at this point in the history
trilom/file-changes-action action has issues and it prevents running
sanity checks locally. Instead of relying on the changed files to know
which wraps are modified by a PR, rely on the added release tags.

Fixes: #121.
  • Loading branch information
xclaesse authored Aug 5, 2021
1 parent b723d9a commit cbf76fb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/sanity_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ jobs:
sudo apt-get -y install build-essential python3-pip ninja-build
pip install meson
- uses: trilom/[email protected]

- name: Sanity Checks
run: |
./tools/sanity_checks.py
19 changes: 9 additions & 10 deletions tools/sanity_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,16 @@ def test_releases(self):
# Verify keys are sorted
self.assertEqual(sorted(releases.keys()), list(releases.keys()))

# Get the list of wraps that has modified packagefiles
with open(Path.home() / 'files.json', 'r') as f:
changed_files = json.load(f)
self.changed_wraps = set()
for f in changed_files:
if f.startswith('subprojects/packagefiles'):
self.changed_wraps.add(f.split('/')[2])

for name, info in releases.items():
print('Checking', name)

# We do extra checks in the case a new release is being made. This
# is because some wraps are not passing all tests but we force making
# them compliant next time we do a release.
versions = info['versions']
latest_tag = f'{name}_{versions[0]}'
extra_checks = latest_tag not in tags

# Make sure we can load wrap file
config = configparser.ConfigParser()
config.read(f'subprojects/{name}.wrap')
Expand All @@ -73,15 +72,15 @@ def test_releases(self):
self.assertIn('source_hash', wrap_section)

# FIXME: Not all wraps currently complies, only check for wraps we modify.
if name in self.changed_wraps:
if extra_checks:
self.assertIn('provide', config.sections())

patch_directory = wrap_section.get('patch_directory')
if patch_directory:
patch_path = Path('subprojects', 'packagefiles', patch_directory)
self.assertTrue(patch_path.is_dir())
# FIXME: Not all wraps currently complies, only check for wraps we modify.
if name in self.changed_wraps:
if extra_checks:
self.assertTrue(Path(patch_path, 'LICENSE.build').is_file())
self.check_files(patch_path)

Expand Down

0 comments on commit cbf76fb

Please sign in to comment.