File: update-spec.yml

package info (click to toggle)
level-zero 1.26.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,468 kB
  • sloc: cpp: 130,327; ansic: 16,197; python: 9,824; makefile: 4
file content (83 lines) | stat: -rw-r--r-- 3,153 bytes parent folder | download | duplicates (2)
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
75
76
77
78
79
80
81
82
83
on:
  pull_request:
    branches: [master]
    paths:
    - .github/workflows/update-spec.yml
  workflow_dispatch:
    inputs:
      repository:
        description: Spec repository from which to generate code
        type: string
        default: oneapi-src/level-zero-spec
      ref:
        description: Ref to checkout from the spec repository
        type: string
        default: master
      version:
        description: Version of the spec to generate code for
        type: string
      branch:
        description: Branch to (force) push generated code to
        type: string
        default: spec-develop

permissions: read-all

concurrency: ${{ github.event_name == 'pull_request' && github.run_id || inputs.branch }}

jobs:
  generate-code:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/setup-python@v5
      with:
        python-version: '3.x'
    - name: Install dependencies
      run: pip install Mako==1.1.0 PyYAML==5.2
    - uses: actions/checkout@v3
      with:
        clean: true
        fetch-depth: 0
        fetch-tags: true
        token: ${{ secrets.TOKEN }}
    - name: Checkout develop branch or create local version
      if: ${{ github.event_name == 'workflow_dispatch' }}
      run: git checkout ${{ inputs.branch }} || git checkout -b ${{ inputs.branch }}
    - name: Reset develop branch to master
      if: ${{ github.event_name == 'workflow_dispatch' }}
      run: git reset --hard origin/master
    - name: Checkout spec repository
      uses: actions/checkout@v4
      with:
        repository: ${{ github.event_name == 'pull_request' && 'oneapi-src/level-zero-spec' || inputs.repository }}
        clean: true
        fetch-depth: 0
        path: spec
        ref: ${{ github.event_name == 'pull_request' && 'master' || inputs.ref }}
    - name: Apply latest spec commit to develop branch
      run: | #bash
        export LANG="C.UTF-8"
        cd spec/scripts
        echo "::group::Generate spec/scripts/input.json"
        python3 ./run.py --debug '--!html' '--!rst' '--!build' --ver ${{ github.event_name == 'pull_request' && '1.10' || inputs.version }}
        echo "::endgroup::"
        cd ..
        echo "::group::Copy generated header files"
        jq -r '.[] | select(.|test("^../include"))' scripts/generated.json | cut -c 4- | sort | xargs -I{} cp -v ./{} ../{}
        echo "::endgroup::"
        cd ..
        echo "::group::Generate source files"
        ./scripts/json2src.py < spec/scripts/input.json --ver ${{ github.event_name == 'pull_request' && '1.10' || inputs.version }} .
        echo "::endgroup::"
        if (($(git diff | tee >(wc -l) >&2) == 0)); then
            echo "::warning::No changes were made to files"
        else
            git config user.email "sys-lzdev@intel.com"
            git config user.name "sys-lzdev"
            spec_ver=$(sed -n 's/^.*version v.*-r\([0-9]*\.[0-9]*\.[0-9]*\)/\1/p' include/ze_api.h)
            git add -u
            git commit -m "Update to spec ${spec_ver}"
        fi
    - name: Push changes to develop branch
      if: ${{ github.event_name == 'workflow_dispatch' }}
      run: git push origin ${{ inputs.branch }} -f