corevalidation.yml 5.3 KB

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