diff --git a/.github/workflows/alchemist-lint.yaml b/.github/workflows/alchemist-lint.yaml new file mode 100644 index 000000000..55b215ecf --- /dev/null +++ b/.github/workflows/alchemist-lint.yaml @@ -0,0 +1,35 @@ +name: Alchemist CFG Lint Check + +on: + push: + branches: [ master ] + paths: + - 'dev/services/alchemist/**' + - 'prod/services/alchemist/**' + - .github/workflows/alchemist-lint.yaml + pull_request: + branches: [ master ] + paths: + - 'dev/services/alchemist/**' + - 'prod/services/alchemist/**' + - .github/workflows/alchemist-lint.yaml + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + # You can use PyPy versions in python-version. + # For example, pypy-2.7 and pypy-3.8 + matrix: + python-version: ["3.9"] + + steps: + - uses: actions/checkout@v3 + # - name: Set up Python ${{ matrix.python-version }} + # uses: actions/setup-python@v4 + # with: + # python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + docker run -t -v ${PWD}:/code/dea-config opendatacube/datacube-alchemist:latest python /code/dea-config/alchemist_lint.py \ No newline at end of file diff --git a/alchemist_lint.py b/alchemist_lint.py new file mode 100644 index 000000000..ee1f6ee6c --- /dev/null +++ b/alchemist_lint.py @@ -0,0 +1,19 @@ +from datacube_alchemist.worker import Alchemist +import os +from fnmatch import fnmatch + +alchemist_service_paths = [ + './dev/services/alchemist', + './prod/services/alchemist' +] + +alchemist_config_file_extensions = [ + '*.yaml', + '*.yml' +] +for alchemist_path in alchemist_service_paths: + for path, subdirs, files in os.walk(alchemist_path): + for name in files: + if any(fnmatch(name, file_extension) for \ + file_extension in alchemist_config_file_extensions): + alchemist = Alchemist(config_file=os.path.join(path, name))