2022-11-18 00:55:08 +03:00
|
|
|
# Copyright (c) Microsoft Corporation.
|
|
|
|
# Licensed under the MIT License.
|
|
|
|
|
2021-10-21 03:04:50 +03:00
|
|
|
name: Spec files check
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
2023-10-26 02:07:02 +03:00
|
|
|
branches: [main, dev, 1.0*, 2.0*, 3.0*, fasttrack/*]
|
2021-10-21 03:04:50 +03:00
|
|
|
pull_request:
|
2023-10-26 02:07:02 +03:00
|
|
|
branches: [main, dev, 1.0*, 2.0*, 3.0*, fasttrack/*]
|
2021-10-21 03:04:50 +03:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
spec-check:
|
|
|
|
name: Spec files check
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
steps:
|
|
|
|
# Checkout the branch of our repo that triggered this action
|
|
|
|
- name: Workflow trigger checkout
|
2023-09-06 07:38:19 +03:00
|
|
|
uses: actions/checkout@v4
|
2021-10-21 03:04:50 +03:00
|
|
|
|
2024-03-29 21:57:42 +03:00
|
|
|
# For consistency, we use the same major/minor version of Python that Azure Linux ships
|
2024-03-25 23:43:13 +03:00
|
|
|
- name: Setup Python 3.12
|
|
|
|
uses: actions/setup-python@v5
|
2021-10-21 03:04:50 +03:00
|
|
|
with:
|
2024-03-25 23:43:13 +03:00
|
|
|
python-version: 3.12
|
2021-10-21 03:04:50 +03:00
|
|
|
|
|
|
|
- name: Get Python dependencies
|
2023-04-13 02:35:42 +03:00
|
|
|
run: python3 -m pip install -r toolkit/scripts/requirements.txt
|
2021-10-21 03:04:50 +03:00
|
|
|
|
|
|
|
- name: Get base commit for PRs
|
|
|
|
if: ${{ github.event_name == 'pull_request' }}
|
|
|
|
run: |
|
|
|
|
git fetch origin ${{ github.base_ref }}
|
2022-10-12 18:30:40 +03:00
|
|
|
echo "base_sha=$(git rev-parse origin/${{ github.base_ref }})" >> $GITHUB_ENV
|
2021-10-21 03:04:50 +03:00
|
|
|
echo "Merging ${{ github.sha }} into ${{ github.base_ref }}"
|
|
|
|
|
|
|
|
- name: Get base commit for Pushes
|
|
|
|
if: ${{ github.event_name == 'push' }}
|
|
|
|
run: |
|
|
|
|
git fetch origin ${{ github.event.before }}
|
2022-10-12 18:30:40 +03:00
|
|
|
echo "base_sha=${{ github.event.before }}" >> $GITHUB_ENV
|
2021-10-21 03:04:50 +03:00
|
|
|
echo "Merging ${{ github.sha }} into ${{ github.event.before }}"
|
|
|
|
|
|
|
|
- name: Get the changed files
|
|
|
|
run: |
|
|
|
|
echo "Files changed: '$(git diff-tree --no-commit-id --name-only -r ${{ env.base_sha }} ${{ github.sha }})'"
|
2022-04-19 07:12:41 +03:00
|
|
|
changed_specs=$(git diff-tree --diff-filter=d --no-commit-id --name-only -r ${{ env.base_sha }} ${{ github.sha }} | { grep "SPECS.*/.*\.spec$" || test $? = 1; })
|
2021-10-21 03:04:50 +03:00
|
|
|
echo "Files to validate: '${changed_specs}'"
|
|
|
|
echo "updated-specs=$(echo ${changed_specs})" >> $GITHUB_ENV
|
|
|
|
|
2024-02-23 03:25:28 +03:00
|
|
|
- name: Get toolchain spec list
|
|
|
|
run: |
|
2024-03-27 02:10:35 +03:00
|
|
|
echo "toolchain-spec-list=$(make --no-print-directory -sC toolkit printvar-toolchain_spec_list)" >> $GITHUB_ENV
|
2024-02-23 03:25:28 +03:00
|
|
|
|
2022-10-12 18:30:40 +03:00
|
|
|
- name: Main branch checkout
|
2023-09-06 07:38:19 +03:00
|
|
|
uses: actions/checkout@v4
|
2021-10-21 03:04:50 +03:00
|
|
|
with:
|
|
|
|
ref: 'main'
|
|
|
|
path: 'main-checkout'
|
2022-10-12 18:30:40 +03:00
|
|
|
|
2021-10-21 03:04:50 +03:00
|
|
|
- name: Verify .spec files
|
2021-10-22 00:50:35 +03:00
|
|
|
if: ${{ env.updated-specs != '' }}
|
2024-03-27 02:10:35 +03:00
|
|
|
run: python3 toolkit/scripts/check_spec_guidelines.py --toolchain_specs "${{ env.toolchain-spec-list }}" --specs ${{ env.updated-specs }}
|