|
| 1 | +# Copyright 2024 Collate |
| 2 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 3 | +# you may not use this file except in compliance with the License. |
| 4 | +# You may obtain a copy of the License at |
| 5 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 6 | +# Unless required by applicable law or agreed to in writing, software |
| 7 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 8 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 9 | +# See the License for the specific language governing permissions and |
| 10 | +# limitations under the License. |
| 11 | + |
| 12 | +name: Validate JSON/YAML |
| 13 | + |
| 14 | +# read-write repo token |
| 15 | +# access to secrets |
| 16 | +on: |
| 17 | + pull_request_target: |
| 18 | + types: [labeled, opened, synchronize, reopened] |
| 19 | + paths: |
| 20 | + - "**.json" |
| 21 | + - "**.yaml" |
| 22 | + - "**.yml" |
| 23 | + |
| 24 | +permissions: |
| 25 | + contents: read |
| 26 | + |
| 27 | +jobs: |
| 28 | + validate-json-yaml: |
| 29 | + runs-on: ubuntu-latest |
| 30 | + permissions: |
| 31 | + pull-requests: write |
| 32 | + steps: |
| 33 | + - name: Wait for the labeler |
| 34 | + uses: lewagon/wait-on-check-action@v1.3.3 |
| 35 | + if: ${{ github.event_name == 'pull_request_target' }} |
| 36 | + with: |
| 37 | + ref: ${{ github.event.pull_request.head.sha }} |
| 38 | + check-name: Team Label |
| 39 | + repo-token: ${{ secrets.GITHUB_TOKEN }} |
| 40 | + wait-interval: 90 |
| 41 | + |
| 42 | + - name: Verify PR labels |
| 43 | + uses: jesusvasquez333/verify-pr-label-action@v1.4.0 |
| 44 | + if: ${{ github.event_name == 'pull_request_target' }} |
| 45 | + with: |
| 46 | + github-token: '${{ secrets.GITHUB_TOKEN }}' |
| 47 | + valid-labels: 'safe to test' |
| 48 | + pull-request-number: '${{ github.event.pull_request.number }}' |
| 49 | + disable-reviews: true # To not auto approve changes |
| 50 | + |
| 51 | + - name: Checkout |
| 52 | + uses: actions/checkout@v3 |
| 53 | + with: |
| 54 | + ref: ${{ github.event.pull_request.head.sha }} |
| 55 | + |
| 56 | + - name: Set up Python 3.9 |
| 57 | + uses: actions/setup-python@v4 |
| 58 | + with: |
| 59 | + python-version: 3.9 |
| 60 | + |
| 61 | + - name: Install Ubuntu related dependencies |
| 62 | + run: | |
| 63 | + sudo apt-get update && sudo apt-get install -y libsasl2-dev unixodbc-dev python3-venv |
| 64 | +
|
| 65 | + - name: Install Python & Openmetadata related dependencies |
| 66 | + run: | |
| 67 | + python3 -m venv env |
| 68 | + source env/bin/activate |
| 69 | + pip install pyyaml |
| 70 | +
|
| 71 | + # Add back linting once we have 10/10 on main |
| 72 | + - name: Code style check |
| 73 | + id: style |
| 74 | + continue-on-error: true |
| 75 | + run: | |
| 76 | + source env/bin/activate |
| 77 | + pip install pyyaml |
| 78 | + ./scripts/validate_json_yaml.sh |
| 79 | +
|
| 80 | + - name: Create a comment in the PR with the instructions |
| 81 | + if: steps.style.outcome != 'success' |
| 82 | + uses: peter-evans/create-or-update-comment@v1 |
| 83 | + with: |
| 84 | + issue-number: ${{ github.event.pull_request.number }} |
| 85 | + body: | |
| 86 | + **JSON/YAML Validations failed.** |
| 87 | +
|
| 88 | + Please run `./scripts/validate_json_yaml.sh` to find any bad json/yaml files and fix them. |
| 89 | + You can also use [pre-commit](https://pre-commit.com/) to automate the Python code formatting. |
| 90 | +
|
| 91 | + You can install the pre-commit hooks with `make install_test precommit_install`. |
| 92 | +
|
| 93 | + - name: Python checkstyle failed, check the comment in the PR |
| 94 | + if: steps.style.outcome != 'success' |
| 95 | + run: | |
| 96 | + exit 1 |
0 commit comments