Skip to content

Commit 978c7e2

Browse files
authored
Merge pull request #326 from henrybear327/ci/skip_ci
CI: Skip pipelines if no source files are changed
2 parents 7dec1c1 + 6e69811 commit 978c7e2

File tree

3 files changed

+83
-70
lines changed

3 files changed

+83
-70
lines changed

.github/workflows/compliance.yml

Lines changed: 0 additions & 17 deletions
This file was deleted.

.github/workflows/docker.yml

Lines changed: 0 additions & 53 deletions
This file was deleted.

.github/workflows/main.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,39 @@ name: CI
33
on: [push, pull_request]
44

55
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+
636
host-x64:
37+
needs: [detect-code-related-file-changes]
38+
if: needs.detect-code-related-file-changes.outputs.has_code_related_changes == 'true'
739
runs-on: ubuntu-22.04
840
steps:
941
- uses: actions/checkout@v4
@@ -39,6 +71,8 @@ jobs:
3971
make ENABLE_EXT_F=0 ENABLE_JIT=1 clean check
4072
4173
host-arm64:
74+
needs: [detect-code-related-file-changes]
75+
if: needs.detect-code-related-file-changes.outputs.has_code_related_changes == 'true'
4276
runs-on: ubuntu-22.04
4377
steps:
4478
- name: checkout code
@@ -67,6 +101,8 @@ jobs:
67101
make ENABLE_EXT_F=0 ENABLE_JIT=1 clean check
68102
69103
coding-style:
104+
needs: [detect-code-related-file-changes]
105+
if: needs.detect-code-related-file-changes.outputs.has_code_related_changes == 'true'
70106
runs-on: ubuntu-22.04
71107
steps:
72108
- uses: actions/checkout@v4
@@ -76,3 +112,50 @@ jobs:
76112
.ci/check-newline.sh
77113
.ci/check-format.sh
78114
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

Comments
 (0)