Skip to content

support pr commit can also build images #753

support pr commit can also build images

support pr commit can also build images #753

Workflow file for this run

name: CI Workflow
on:
# Run this workflow every time a new commit pushed to upstream/fork repository.
# Run workflow on fork repository will help contributors find and resolve issues before sending a PR.
pull_request:
push:
# Exclude branches created by Dependabot to avoid triggering current workflow
# for PRs initiated by Dependabot.
branches-ignore:
- 'dependabot/**'
env:
GO_VERSION: "1.21.6"
jobs:
lint:
name: lint
runs-on: ubuntu-22.04
steps:
- name: checkout code
uses: actions/checkout@v4
- name: install Go
uses: actions/setup-go@v5
with:
go-version: "1.21"
- name: verify license
run: hack/verify-license.sh
- name: go tidy
run: make tidy
- name: lint
run: make lint
- name: import alias
run: hack/verify-import-aliases.sh
test:
name: Unit test
needs: lint # rely on lint successful completion
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Checkout submodule
uses: Mushus/[email protected]
with:
basePath: # optional, default is .
submodulePath: libvgpu
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: "1.21"
- run: make tidy
- run: make test
- name: Upload coverage to Codecov
# Prevent running from the forked repository that doesn't need to upload coverage.
# In addition, running on the forked repository would fail as missing the necessary secret.
if: ${{ github.repository == 'Project-HAMi/HAMi' }}
uses: codecov/codecov-action@v4
with:
# Even though token upload token is not required for public repos,
# but adding a token might increase successful uploads as per:
# https://community.codecov.com/t/upload-issues-unable-to-locate-build-via-github-actions-api/3954
token: ${{secrets.CODECOV_TOKEN}}
files: ./_output/coverage/coverage.out
flags: unittests
fail_ci_if_error: false
verbose: true
build:
name: compile
needs: test # rely on test successful completion
runs-on: ubuntu-latest
env:
IMAGE: ${{ secrets.IMAGE || 'projecthami/hami' }}
steps:
- name: Free disk space
# https://github.com/actions/virtual-environments/issues/709
run: |
echo "=========original CI disk space"
df -h
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
echo "=========after clean up, the left CI disk space"
df -h
- name: Checkout
uses: actions/checkout@v4
- name: Checkout submodule
uses: Mushus/[email protected]
with:
basePath: # optional, default is .
submodulePath: libvgpu
- name: Get branch name
uses: nelonoel/[email protected]
# - name: Docker Login
# uses: docker/[email protected]
# with:
# username: ${{ secrets.DOCKERHUB_TOKEN }}
# password: ${{ secrets.DOCKERHUB_PASSWD }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: image=moby/buildkit:master
- name: install Go
uses: actions/setup-go@v5
with:
go-version: "1.21"
- name: Generating image tag
id: runtime-tag
run: |
echo tag="$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- run: SHORT_VERSION=${{ steps.runtime-tag.outputs.tag }} bash ./hack/build.sh