Skip to content

Update README

Update README #480

Workflow file for this run

name: Build
on:
pull_request:
workflow_dispatch:
push:
branches-ignore:
- 'dependabot/**'
- 'gh-pages'
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 15
# Skip duplicate build on pull_request if pull request uses branch from the same repository
if: github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# Required to deduce version from git tags
fetch-depth: 0
- name: Skip build if not needed
id: skipper
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
declare -r PREV_SHA="$(git rev-parse HEAD~1 2>/dev/null || true)"
if [ "$PREV_SHA" == "HEAD~1" ]; then
echo "It's an initial commit."
echo "skip=false" >> $GITHUB_OUTPUT
exit 0
fi
declare -r RUNS="$(gh api \
-H "Accept: application/vnd.github+json" \
/repos/${{ github.repository }}/actions/runs?head_sha=$PREV_SHA)"
declare -r BUILD_SUCCESS="$(echo "$RUNS" | jq -r 'limit(1; .workflow_runs[] | select(.name == "Build" and (.conclusion == "success" or .conclusion == "skipped"))) | .conclusion')"
if [ -z "$BUILD_SUCCESS" ]; then
echo "Last commit did not pass Build"
echo "skip=false" >> $GITHUB_OUTPUT
exit 0
fi
echo "Last commit passed Build"
case '${{ github.event_name }}' in
push)
SHAS=(${{ join(github.event.commits.*.id, ' ') || 'none' }})
CHANGED_FILES="$(git diff --name-only --diff-filter=d "${SHAS[0]}~1" "${SHAS[-1]}")"
;;
pull_request)
CHANGED_FILES="$(git diff --name-only --diff-filter=d ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }})"
;;
*)
echo "Event ${{ github.event_name }} should not be skipped."
echo "skip=false" >> $GITHUB_OUTPUT
exit 0
esac
NOT_SKIPPED="$(echo "$CHANGED_FILES" \
| grep -v -e "^[^/]*\.md" -e "^.github/.*\.md" -e "^.gitignore" -e "^docs/.*" -e "^gradle.properties" || true)"
if [ -z "$NOT_SKIPPED" ]; then
echo "No important files detected. Skipping Build."
echo "skip=true" >> $GITHUB_OUTPUT
else
echo -e "Important files detected:\n$(echo $NOT_SKIPPED | head -n 10)"
echo "skip=false" >> $GITHUB_OUTPUT
fi
echo -e "Changed files:\n$CHANGED_FILES"
- name: Setup JDK
uses: actions/setup-java@v4
if: steps.skipper.outputs.skip != 'true'
with:
java-version: 21
distribution: temurin
- name: Validate gradle wrapper
uses: gradle/actions/wrapper-validation@v4
if: steps.skipper.outputs.skip != 'true'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
if: steps.skipper.outputs.skip != 'true'
with:
# Publish dependency graph only for the default branch
dependency-graph: |
${{ (github.event.repository != null && github.ref_name == github.event.repository.default_branch)
&& 'generate-and-submit' || 'disabled' }}
- name: Build
if: steps.skipper.outputs.skip != 'true'
run: ./gradlew build coverage
- name: Publish Coverage Report
uses: codecov/codecov-action@v4
# Publish coverage only for the default branch
if: |
steps.skipper.outputs.skip != 'true'
&& github.event.repository != null
&& github.ref_name == github.event.repository.default_branch
with:
token: ${{ secrets.CODECOV_TOKEN }}
override_commit: ${{ github.event.workflow_run.head_sha }}
override_branch: ${{ github.event.workflow_run.head_branch }}
override_build: ${{ github.event.workflow_run.id }}
disable_search: true
files: build/reports/kover/report.xml