1# Copyright 2021, Proofcraft Pty Ltd
2#
3# SPDX-License-Identifier: BSD-2-Clause
4
5# sel4test hardware builds and runs
6#
7# See sel4test-hw/builds.yml in the repo seL4/ci-actions for configs.
8
9name: seL4Test HW
10
11on:
12  # needs PR target for secrets access; guard by requiring label
13  pull_request_target:
14    types: [opened, reopened, synchronize, labeled]
15
16# downgrade permissions to read-only as you would have in a standard PR action
17permissions:
18  contents: read
19
20jobs:
21  hw-build:
22    name: HW Build
23    runs-on: ubuntu-latest
24    if: ${{ github.event_name == 'push' ||
25            github.event_name == 'pull_request_target' &&
26              github.event.action != 'labeled' &&
27              (contains(github.event.pull_request.labels.*.name, 'hw-build') ||
28               contains(github.event.pull_request.labels.*.name, 'hw-test')) ||
29            github.event_name == 'pull_request_target' &&
30              github.event.action == 'labeled' &&
31              (github.event.label.name == 'hw-build' ||
32               github.event.label.name == 'hw-test') }}
33    strategy:
34      fail-fast: false
35      matrix:
36        march: [armv7a, armv8a, nehalem]
37        compiler: [gcc, clang]
38        include:
39          - march: rv64imac
40            compiler: gcc
41    steps:
42    - name: Build
43      uses: seL4/ci-actions/sel4test-hw@master
44      with:
45        march: ${{ matrix.march }}
46        compiler: ${{ matrix.compiler }}
47        sha: ${{ github.event.pull_request.head.sha }}
48    - name: Upload images
49      uses: actions/upload-artifact@v2
50      with:
51        name: images-${{ matrix.march }}-${{ matrix.compiler }}
52        path: '*-images.tar.gz'
53
54  the_matrix:
55    name: Matrix
56    needs: hw-build
57    runs-on: ubuntu-latest
58    outputs:
59      matrix: ${{ steps.matrix.outputs.matrix }}
60    steps:
61    - id: matrix
62      uses: seL4/ci-actions/sel4test-hw-matrix@master
63
64  hw-run:
65    name: HW Run
66    runs-on: ubuntu-latest
67    needs: the_matrix
68    if: ${{ github.repository_owner == 'seL4' &&
69            (github.event_name == 'push' ||
70             github.event_name == 'pull_request_target' &&
71               github.event.action != 'labeled' &&
72               contains(github.event.pull_request.labels.*.name, 'hw-test') ||
73             github.event_name == 'pull_request_target' &&
74               github.event.action == 'labeled' &&
75               github.event.label.name == 'hw-test') }}
76    strategy:
77      fail-fast: false
78      matrix: ${{ fromJson(needs.the_matrix.outputs.matrix) }}
79    steps:
80      - name: Get machine queue
81        uses: actions/checkout@v2
82        with:
83          repository: seL4/machine_queue
84          path: machine_queue
85          token: ${{ secrets.PRIV_REPO_TOKEN }}
86      - name: Download image
87        uses: actions/download-artifact@v2
88        with:
89          name: images-${{ matrix.march }}-${{ matrix.compiler }}
90      - name: Run
91        uses: seL4/ci-actions/sel4test-hw-run@master
92        with:
93          platform: ${{ matrix.platform }}
94          compiler: ${{ matrix.compiler }}
95          mode: ${{ matrix.mode }}
96          index: $${{ strategy.job-index }}
97        env:
98          HW_SSH: ${{ secrets.HW_SSH }}
99