@@ -3,7 +3,39 @@ name: CI
3
3
on : [push, pull_request]
4
4
5
5
jobs :
6
+ detect-code-related-file-changes :
7
+ runs-on : ubuntu-22.04
8
+ outputs :
9
+ has_code_related_changes : ${{ steps.set_has_code_related_changes.outputs.has_code_related_changes }}
10
+ steps :
11
+ - name : Check out the repo
12
+ uses : actions/checkout@v4
13
+ - name : Test changed files
14
+ id : changed-files
15
+ uses : tj-actions/changed-files@v40
16
+ with :
17
+ files : |
18
+ .ci/**
19
+ build/**
20
+ mk/**
21
+ src/**
22
+ tests/**
23
+ tools/**
24
+ .clang-format
25
+ Dockerfile
26
+ Makefile
27
+ - name : Set has_code_related_changes
28
+ id : set_has_code_related_changes
29
+ run : |
30
+ if [[ ${{ steps.changed-files.outputs.any_changed }} == true ]]; then
31
+ echo "has_code_related_changes=true" >> $GITHUB_OUTPUT
32
+ else
33
+ echo "has_code_related_changes=false" >> $GITHUB_OUTPUT
34
+ fi
35
+
6
36
host-x64 :
37
+ needs : [detect-code-related-file-changes]
38
+ if : needs.detect-code-related-file-changes.outputs.has_code_related_changes == 'true'
7
39
runs-on : ubuntu-22.04
8
40
steps :
9
41
- uses : actions/checkout@v4
39
71
make ENABLE_EXT_F=0 ENABLE_JIT=1 clean check
40
72
41
73
host-arm64 :
74
+ needs : [detect-code-related-file-changes]
75
+ if : needs.detect-code-related-file-changes.outputs.has_code_related_changes == 'true'
42
76
runs-on : ubuntu-22.04
43
77
steps :
44
78
- name : checkout code
67
101
make ENABLE_EXT_F=0 ENABLE_JIT=1 clean check
68
102
69
103
coding-style :
104
+ needs : [detect-code-related-file-changes]
105
+ if : needs.detect-code-related-file-changes.outputs.has_code_related_changes == 'true'
70
106
runs-on : ubuntu-22.04
71
107
steps :
72
108
- uses : actions/checkout@v4
@@ -76,3 +112,50 @@ jobs:
76
112
.ci/check-newline.sh
77
113
.ci/check-format.sh
78
114
shell : bash
115
+
116
+ compliance-test :
117
+ needs : [detect-code-related-file-changes]
118
+ if : needs.detect-code-related-file-changes.outputs.has_code_related_changes == 'true'
119
+ runs-on : ubuntu-latest
120
+ steps :
121
+ - uses : actions/checkout@v4
122
+ - name : install-dependencies
123
+ run : |
124
+ .ci/riscv-toolchain-install.sh
125
+ shell : bash
126
+ - name : architectural test
127
+ run : |
128
+ .ci/riscv-tests.sh
129
+ shell : bash
130
+
131
+ # https://docs.docker.com/build/ci/github-actions/multi-platform/
132
+ docker-hub-build-and-publish :
133
+ needs : [detect-code-related-file-changes]
134
+ if : needs.detect-code-related-file-changes.outputs.has_code_related_changes == 'true'
135
+ runs-on : ubuntu-22.04
136
+ steps :
137
+ - name : Check out the repo
138
+ uses : actions/checkout@v4
139
+ - name : Set up QEMU
140
+ uses : docker/setup-qemu-action@v3
141
+ - name : Set up Docker Buildx
142
+ uses : docker/setup-buildx-action@v3
143
+ - name : Login to Docker Hub
144
+ uses : docker/login-action@v3
145
+ if : ${{ github.event_name == 'push'}}
146
+ with :
147
+ username : ${{ secrets.DOCKERHUB_USERNAME }}
148
+ password : ${{ secrets.DOCKERHUB_ACCESS_TOKEN }}
149
+ - name : Get short commit SHA1
150
+ if : ${{ github.event_name == 'push'}}
151
+ shell : bash
152
+ run : |
153
+ echo "short_hash=$(git rev-parse --short "$GITHUB_SHA")" >> "$GITHUB_ENV"
154
+ - name : Build and push
155
+ if : ${{ github.event_name == 'push'}}
156
+ uses : docker/build-push-action@v5
157
+ with :
158
+ context : .
159
+ platforms : linux/amd64,linux/arm64/v8
160
+ tags : sysprog21/rv32emu:latest, sysprog21/rv32emu:${{ env.short_hash }}
161
+
0 commit comments