fix(LineLengthChecker): do not crash if files contain invalid UTF-8 c… #122
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# SPDX-FileCopyrightText: 2023 Pipeline Helper Contributors | |
# | |
# SPDX-License-Identifier: CC0-1.0 | |
name: Continuous Integration | |
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
tags: | |
- 'v[0-9]+.[0-9]+.[0-9]+' | |
env: | |
java: 17 | |
java-distribution: "temurin" | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup Java | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '${{ env.java }}' | |
distribution: '${{ env.java-distribution }}' | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Cache Maven packages | |
uses: actions/cache@v4 | |
with: | |
path: ~/.m2 | |
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} | |
restore-keys: ${{ runner.os }}-m2 | |
- name: Build | |
run: mvn package -B -DskipTests=true | |
- name: Update dependency graph | |
uses: advanced-security/maven-dependency-submission-action@49866fead7de0b0083b89f5f653f9620548ccddf | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: pipeline-helper.jar | |
path: target/pipeline-helper-*-shaded.jar | |
release: | |
needs: [build, test] | |
if: startsWith(github.ref, 'refs/tags/v') | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get tag | |
id: get_version | |
run: echo ::set-output name=VERSION::$(echo $GITHUB_REF | cut -d / -f 3) | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.get_version.outputs.VERSION }} | |
release_name: Release ${{ steps.get_version.outputs.VERSION }} | |
draft: false | |
prerelease: false | |
- name: Download pre-build artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: pipeline-helper.jar | |
path: release | |
- name: Get artifact name | |
id: get_artifact_name | |
run: | | |
cd release | |
mv *.jar pipeline-helper.jar | |
echo "ARTIFACT=$(ls *.jar)" >> $GITHUB_OUTPUT | |
- name: Upload Release Asset | |
id: upload-release-asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: release/${{ steps.get_artifact_name.outputs.ARTIFACT }} | |
asset_name: ${{ steps.get_artifact_name.outputs.ARTIFACT }} | |
asset_content_type: application/zip | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup Java | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '${{ env.java }}' | |
distribution: '${{ env.java-distribution }}' | |
- uses: actions/checkout@v4 | |
- name: Cache Maven packages | |
uses: actions/cache@v4 | |
with: | |
path: ~/.m2 | |
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} | |
restore-keys: ${{ runner.os }}-m2 | |
- name: Tests | |
run: mvn -B test | |
checkstyle: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup Java | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '${{ env.java }}' | |
distribution: '${{ env.java-distribution }}' | |
- uses: actions/checkout@v4 | |
- name: Cache Maven packages | |
uses: actions/cache@v4 | |
with: | |
path: ~/.m2 | |
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} | |
restore-keys: ${{ runner.os }}-m2 | |
- name: Checkstyle | |
run: mvn -B checkstyle:check | |
- name: Fail build if there are Checkstyle violations | |
run: | | |
! grep -q "^<error" target/checkstyle-result.xml | |
code-formatting: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup Java | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '${{ env.java }}' | |
distribution: '${{ env.java-distribution }}' | |
- uses: actions/checkout@v4 | |
- name: Cache Maven packages | |
uses: actions/cache@v4 | |
with: | |
path: ~/.m2 | |
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} | |
restore-keys: ${{ runner.os }}-m2 | |
- name: Run `mvn spotless:apply` locally if the following check is failing | |
run: "true" | |
- name: Spotless code formatting | |
run: mvn -B spotless:check |