Skip to content

CI

CI #526

Workflow file for this run

# Copyright 2023 Korandoru Contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
merge_group:
schedule:
- cron: '4 2 * * *'
# Concurrency strategy:
# github.workflow: distinguish this workflow from others
# github.event_name: distinguish `push` event from `pull_request` event
# github.event.number: set to the number of the pull request if `pull_request` event
# github.run_id: otherwise, it's a `push` or `schedule` event, only cancel if we rerun the workflow
#
# Reference:
# https://docs.github.com/en/actions/using-jobs/using-concurrency
# https://docs.github.com/en/actions/learn-github-actions/contexts#github-context
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.number || github.run_id }}
cancel-in-progress: true
jobs:
check:
if: (github.event_name != 'schedule') || (github.repository == 'korandoru/hawkeye')
name: Check and build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Cache local Maven repository
uses: actions/cache@v3
timeout-minutes: 5
with:
path: |
~/.m2/repository/*/*/*
!~/.m2/repository/io/korandoru/hawkeye
key: ${{ matrix.os }}-m2-dependencies-core-modules-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ matrix.os }}-m2-dependencies-core-modules-
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
- name: Check and build
run: |
./mvnw spotless:check
./mvnw clean install -DskipTests
unittest:
if: (github.event_name != 'schedule') || (github.repository == 'korandoru/hawkeye')
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
name: Run unit tests ${{ matrix.os }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Cache local Maven repository
uses: actions/cache@v3
timeout-minutes: 5
with:
path: |
~/.m2/repository/*/*/*
!~/.m2/repository/io/korandoru/hawkeye
key: ${{ matrix.os }}-m2-dependencies-core-modules-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ matrix.os }}-m2-dependencies-core-modules-
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
- name: Maven verify
run: ./mvnw clean verify
docker:
if: (github.event_name != 'schedule') || (github.repository == 'korandoru/hawkeye')
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, buildjet-4vcpu-ubuntu-2204-arm]
name: [hawkeye, hawkeye-native]
file: [Dockerfile, Dockerfile.native]
exclude:
- name: hawkeye
file: Dockerfile.native
- name: hawkeye-native
file: Dockerfile
runs-on: ${{matrix.os}}
name: Build and test ${{matrix.name}} ${{matrix.os}}
steps:
- uses: actions/checkout@v3
- name: Build and load
uses: docker/build-push-action@v3
with:
context: .
file: ${{matrix.file}}
tags: ${{matrix.name}}:ci
outputs: type=docker
- name: Sanity check
run: docker run --rm -v $(pwd):/github/workspace ${{matrix.name}}:ci check
required:
name: Required
runs-on: ubuntu-latest
if: ${{ always() && ((github.event_name != 'schedule') || (github.repository == 'korandoru/hawkeye')) }}
needs:
- check
- docker
- unittest
steps:
- name: Guardian
run: |
if [[ ! ( \
"${{ needs.check.result }}" == "success" \
&& "${{ needs.docker.result }}" == "success" \
&& "${{ needs.unittest.result }}" == "success" \
) ]]; then
echo "Required jobs haven't been completed successfully."
exit -1
fi