From 876718d003e4fdce764d3da84b4f114670bd02fd Mon Sep 17 00:00:00 2001 From: btwonion Date: Fri, 29 Mar 2024 14:10:17 +0100 Subject: [PATCH] add ci --- .github/workflows/build-commit.yml | 39 +++++++++++++++++++++++ .github/workflows/build-pull-request.yml | 29 +++++++++++++++++ .github/workflows/ktlint-commit.yml | 22 +++++++++++++ .github/workflows/ktlint-pull-request.yml | 20 ++++++++++++ 4 files changed, 110 insertions(+) create mode 100644 .github/workflows/build-commit.yml create mode 100644 .github/workflows/build-pull-request.yml create mode 100644 .github/workflows/ktlint-commit.yml create mode 100644 .github/workflows/ktlint-pull-request.yml diff --git a/.github/workflows/build-commit.yml b/.github/workflows/build-commit.yml new file mode 100644 index 0000000..79431c6 --- /dev/null +++ b/.github/workflows/build-commit.yml @@ -0,0 +1,39 @@ +# Used when a commit is pushed to the repository +# This makes use of caching for faster builds and uploads the resulting artifacts +name: build-commit + +on: [ push ] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Extract current branch name + shell: bash + # bash pattern expansion to grab branch name without slashes + run: ref="${GITHUB_REF#refs/heads/}" && echo "branch=${ref////-}" >> $GITHUB_OUTPUT + id: ref + - name: Checkout sources + uses: actions/checkout@v4 + - name: Set up JDK + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: 17 + - name: Initialize caches + uses: actions/cache@v4 + with: + path: | + ~/.gradle/caches + ~/.gradle/loom-cache + ~/.gradle/wrapper + key: ${{ runner.os }}-build-commit-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-build-commit- + - name: Build artifacts + run: ./gradlew build + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: telekinesis-artifacts-${{ steps.ref.outputs.branch }} + path: build/libs/*.jar diff --git a/.github/workflows/build-pull-request.yml b/.github/workflows/build-pull-request.yml new file mode 100644 index 0000000..4802482 --- /dev/null +++ b/.github/workflows/build-pull-request.yml @@ -0,0 +1,29 @@ +# Used when building external pull requests +# We don't want to publish build artifacts or expose our other caches to possibly untrusted code +name: build-pull-request + +on: [ pull_request ] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v4 + - name: Initialize caches + uses: actions/cache@v4 + with: + path: | + ~/.gradle/caches + ~/.gradle/loom-cache + ~/.gradle/wrapper + key: ${{ runner.os }}-build-external-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-build-external- + - name: Set up JDK + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: 17 + - name: Build artifacts + run: ./gradlew build diff --git a/.github/workflows/ktlint-commit.yml b/.github/workflows/ktlint-commit.yml new file mode 100644 index 0000000..260731a --- /dev/null +++ b/.github/workflows/ktlint-commit.yml @@ -0,0 +1,22 @@ +name: ktlint-commit + +on: [ push ] + +jobs: + ktlint: + name: Check Code Quality + runs-on: ubuntu-latest + + steps: + - name: Clone repo + uses: actions/checkout@v4 + with: + fetch-depth: 1 + - name: ktlint + uses: ScaCap/action-ktlint@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + reporter: github-check + filter_mode: nofilter + level: info + fail_on_error: true diff --git a/.github/workflows/ktlint-pull-request.yml b/.github/workflows/ktlint-pull-request.yml new file mode 100644 index 0000000..174805d --- /dev/null +++ b/.github/workflows/ktlint-pull-request.yml @@ -0,0 +1,20 @@ +name: ktlint-pull-request + +on: [ pull_request ] + +jobs: + ktlint: + name: Check Code Quality + runs-on: ubuntu-latest + + steps: + - name: Clone repo + uses: actions/checkout@v4 + with: + fetch-depth: 1 + - name: ktlint + uses: ScaCap/action-ktlint@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + reporter: github-pr-review + level: info