forked from open-edge-platform/edge-microvisor-toolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
74 lines (61 loc) · 2.55 KB
/
check-spec.yml
File metadata and controls
74 lines (61 loc) · 2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
name: Spec files check
on:
pull_request:
branches: [main, 3.0, 3.0-dev]
types: [opened, synchronize, reopened]
paths:
- .github/workflows/check-spec.yml
- '**.spec'
permissions: read-all
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
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
# For consistency, we use the same major/minor version of Python that Azure Linux ships
- name: Setup Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Get Python dependencies
run: python3 -m pip install -r toolkit/scripts/requirements.txt
- name: Get base commit for PRs
if: ${{ github.event_name == 'pull_request' }}
run: |
base_ref="${BASE_REF}"
echo "base_sha=$(git rev-parse origin/$base_ref)" >> "$GITHUB_ENV"
echo "Merging ${{ github.sha }} into $base_ref"
env:
BASE_REF: ${{ github.base_ref }}
- name: Get base commit for Pushes
if: ${{ github.event_name == 'push' }}
run: |
echo "base_sha=${{ github.event.before }}" >> "$GITHUB_ENV"
echo "Merging ${{ github.sha }} into ${{ github.event.before }}"
- name: Get the changed files
run: |
git config --global --add safe.directory '*'
echo "Files changed: '$(git diff-tree --no-commit-id --name-only -r ${{ env.base_sha }} ${{ github.sha }})'"
changed_specs=$(git diff-tree --diff-filter=d --no-commit-id --name-only -r ${{ env.base_sha }} ${{ github.sha }} | { grep "SPECS.*/.*\.spec$" || test $? = 1; } | tr '\n' ' ' )
echo "Files to validate: '${changed_specs}'"
echo "updated-specs=${changed_specs}" >> "$GITHUB_ENV"
- name: Get toolchain spec list
run: |
echo "toolchain-spec-list=$(make --no-print-directory -sC toolkit printvar-toolchain_spec_list)" >> "$GITHUB_ENV"
- name: Main branch checkout
uses: actions/checkout@v4
with:
ref: '3.0'
path: '3.0-checkout'
persist-credentials: false
- name: Verify .spec files
if: ${{ env.updated-specs != '' }}
run: python3 toolkit/scripts/check_spec_guidelines.py --toolchain_specs "${{ env.toolchain-spec-list }}" --specs ${{ env.updated-specs }}