Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: Skip pipelines if no source files are changed #326

Merged
merged 1 commit into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions .github/workflows/compliance.yml

This file was deleted.

53 changes: 0 additions & 53 deletions .github/workflows/docker.yml

This file was deleted.

83 changes: 83 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,39 @@ name: CI
on: [push, pull_request]

jobs:
detect-code-related-file-changes:
runs-on: ubuntu-22.04
outputs:
has_code_related_changes: ${{ steps.set_has_code_related_changes.outputs.has_code_related_changes }}
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Test changed files
id: changed-files
uses: tj-actions/changed-files@v40
with:
files: |
.ci/**
build/**
mk/**
src/**
tests/**
tools/**
.clang-format
Dockerfile
Makefile
- name: Set has_code_related_changes
id: set_has_code_related_changes
run: |
if [[ ${{ steps.changed-files.outputs.any_changed }} == true ]]; then
echo "has_code_related_changes=true" >> $GITHUB_OUTPUT
else
echo "has_code_related_changes=false" >> $GITHUB_OUTPUT
fi

host-x64:
needs: [detect-code-related-file-changes]
if: needs.detect-code-related-file-changes.outputs.has_code_related_changes == 'true'
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -39,6 +71,8 @@ jobs:
make ENABLE_EXT_F=0 ENABLE_JIT=1 clean check

host-arm64:
needs: [detect-code-related-file-changes]
if: needs.detect-code-related-file-changes.outputs.has_code_related_changes == 'true'
runs-on: ubuntu-22.04
steps:
- name: checkout code
Expand Down Expand Up @@ -67,6 +101,8 @@ jobs:
make ENABLE_EXT_F=0 ENABLE_JIT=1 clean check

coding-style:
needs: [detect-code-related-file-changes]
if: needs.detect-code-related-file-changes.outputs.has_code_related_changes == 'true'
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
Expand All @@ -76,3 +112,50 @@ jobs:
.ci/check-newline.sh
.ci/check-format.sh
shell: bash

compliance-test:
needs: [detect-code-related-file-changes]
if: needs.detect-code-related-file-changes.outputs.has_code_related_changes == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: install-dependencies
run: |
.ci/riscv-toolchain-install.sh
shell: bash
- name: architectural test
run: |
.ci/riscv-tests.sh
shell: bash

# https://docs.docker.com/build/ci/github-actions/multi-platform/
docker-hub-build-and-publish:
needs: [detect-code-related-file-changes]
if: needs.detect-code-related-file-changes.outputs.has_code_related_changes == 'true'
runs-on: ubuntu-22.04
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
if: ${{ github.event_name == 'push'}}
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }}
- name: Get short commit SHA1
if: ${{ github.event_name == 'push'}}
shell: bash
run: |
echo "short_hash=$(git rev-parse --short "$GITHUB_SHA")" >> "$GITHUB_ENV"
- name: Build and push
if: ${{ github.event_name == 'push'}}
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64/v8
tags: sysprog21/rv32emu:latest, sysprog21/rv32emu:${{ env.short_hash }}