]> begriffs open source - cmsis/blob - .github/workflows/corevalidation.yml
CoreValidation: Checkout the PR, not develop branch
[cmsis] / .github / workflows / corevalidation.yml
1 # This workflow is triggered whenever "Caller CoreValidation" workflow is completed (which is called by PR).
2 # This workflow ideally should be triggered also by PR, but forked PR has limited permissions which does not
3 # allow to use `configure-aws-credentials` actions and using secrets.
4 # It will update its status back to the caller PR as "CoreValidation" check name
5 name: CoreValidation
6 on:
7   workflow_run:
8     workflows:
9       - Caller CoreValidation
10     types:
11       - completed
12
13 # The env variables relate to an ARM AWS account for CMSIS_5
14 # If you are forking CMSIS_5 repo, please use your own info.
15 env:
16   AWS_ASSUME_ROLE: ${{ secrets.AWS_ASSUME_ROLE }}
17   AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
18   AWS_IAM_PROFILE: ${{ secrets.AWS_IAM_PROFILE }}
19   AWS_S3_BUCKET_NAME: ${{ secrets.AWS_S3_BUCKET_NAME }}
20   AWS_SECURITY_GROUP_ID: ${{ secrets.AWS_SECURITY_GROUP_ID }}
21   AWS_SUBNET_ID: ${{ secrets.AWS_SUBNET_ID }}
22
23 jobs:
24   set_pending_status_to_pr:
25     runs-on: ubuntu-latest
26     steps:
27       - name: Set a pending status to the PR
28         env:
29           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30         run: |
31           curl --request POST \
32             --url https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.event.workflow_run.head_commit.id }} \
33             --header "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
34             --header 'content-type: application/json' \
35             --data '{
36               "state": "pending",
37               "context": "CoreValidation",
38               "target_url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
39               }' \
40             --fail
41
42   ci_test:
43     runs-on: ubuntu-latest
44     needs: set_pending_status_to_pr
45     permissions:
46       id-token: write
47       contents: read
48     outputs:
49       avhresult: ${{ steps.avh.conclusion }}
50       testbadge: ${{ steps.avh.outputs.badge }}
51     steps:
52     - name: Download workflow artifact
53       uses: dawidd6/action-download-artifact@v2
54       with:
55         github_token: ${{ secrets.GITHUB_TOKEN }}
56         workflow: caller-corevalidation.yml
57         run_id: ${{ github.event.workflow_run.id }}
58
59     - name: Read the pr_num file
60       id: pr_num_reader
61       uses: juliangruber/read-file-action@v1.1.6
62       with:
63         path: ./pr_number/pr_number
64         trim: true
65
66     - name: Clone this repo
67       uses: actions/checkout@v3
68       with:
69         fetch-depth: 0
70
71     - name: Checkout PR
72       env:
73         GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
74       run: |
75         gh pr checkout ${{ steps.pr_num_reader.outputs.content }}
76
77     - name: Set up Python 3.10
78       uses: actions/setup-python@v4
79       with:
80         python-version: '3.10'
81
82     - name: Install AVH Client for Python
83       run: |
84         pip install git+https://github.com/ARM-software/avhclient.git@v0.1
85
86     - uses: ammaraskar/gcc-problem-matcher@master
87
88     - name: Configure AWS Credentials
89       uses: aws-actions/configure-aws-credentials@v1-node16
90       with:
91         role-to-assume: ${{ env.AWS_ASSUME_ROLE }}
92         aws-region: ${{ env.AWS_DEFAULT_REGION }}
93
94     - name: Run tests
95       id: avh
96       run: |
97         avhclient -b aws execute --specfile CMSIS/CoreValidation/Project/avh.yml
98
99     - name: Archive build results
100       uses: actions/upload-artifact@v3
101       with:
102         name: builds
103         path: CMSIS/CoreValidation/Project/Core_Validation-*.zip
104         retention-days: 1
105         if-no-files-found: error
106       if: always()
107
108     - name: Archive test results
109       uses: actions/upload-artifact@v3
110       with:
111         name: tests
112         path: CMSIS/CoreValidation/Project/Core_Validation-*.junit
113         retention-days: 1
114         if-no-files-found: error
115       if: always()
116
117     - name: Archive event file
118       uses: actions/upload-artifact@v3
119       with:
120         name: EventFile
121         path: ${{ github.event_path }}
122
123   set_success_status_to_pr:
124     runs-on: ubuntu-latest
125     needs: ci_test
126     if: ${{ success() }}
127     steps:
128       - name: Set success status to the PR
129         env:
130           GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
131         run: |
132           curl --request POST \
133             --url https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.event.workflow_run.head_commit.id }} \
134             --header "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
135             --header 'content-type: application/json' \
136             --data '{
137               "state": "success",
138               "context": "CoreValidation",
139               "target_url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
140               }' \
141             --fail
142
143   set_failure_status_to_pr:
144     runs-on: ubuntu-latest
145     needs: ci_test
146     if: ${{ failure() }}
147     steps:
148       - name: Set failure status to the PR
149         env:
150           GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
151         run: |
152           curl --request POST \
153             --url https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.event.workflow_run.head_commit.id }} \
154             --header "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
155             --header 'content-type: application/json' \
156             --data '{
157               "state": "failure",
158               "context": "CoreValidation",
159               "target_url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
160               }' \
161             --fail