From be0882a9b6345551d6006813a1fe87c764ff238d Mon Sep 17 00:00:00 2001 From: Hugo van Rijswijk Date: Tue, 15 Oct 2024 11:43:14 +0200 Subject: [PATCH] build(CI): add shared setup action steps (#403) --- .github/setup/action.yml | 20 ++++++++++++++++++ .github/workflows/scala.yml | 42 ++++++------------------------------- 2 files changed, 26 insertions(+), 36 deletions(-) create mode 100644 .github/setup/action.yml diff --git a/.github/setup/action.yml b/.github/setup/action.yml new file mode 100644 index 0000000..bf1c65c --- /dev/null +++ b/.github/setup/action.yml @@ -0,0 +1,20 @@ +name: "Setup CI" + +description: "Set up Java, sbt and cache for CI" + +inputs: + java-version: + description: "The Java version to use" + default: "21" + required: false + +runs: + using: "composite" + steps: + - uses: actions/setup-java@v4 + name: Set up JDK + with: + distribution: "temurin" + java-version: "${{ inputs.java-version }}" + cache: "sbt" + - uses: sbt/setup-sbt@v1 diff --git a/.github/workflows/scala.yml b/.github/workflows/scala.yml index f6dc7f5..af00cc7 100644 --- a/.github/workflows/scala.yml +++ b/.github/workflows/scala.yml @@ -19,12 +19,7 @@ jobs: # Fetch all tags - run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* - run: git fetch --tags - - name: Set up JDK - uses: actions/setup-java@v4 - with: - distribution: temurin - java-version: 21 - cache: 'sbt' + - uses: ./.github/setup - name: Compile code run: sbt "compile; docs3/mdoc --check; mimaReportBinaryIssues" @@ -32,12 +27,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Set up JDK - uses: actions/setup-java@v4 - with: - distribution: temurin - java-version: 21 - cache: 'sbt' + - uses: ./.github/setup - name: Check formatting run: sbt scalafmtCheckAll @@ -50,12 +40,7 @@ jobs: runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 - - name: Set up JDK - uses: actions/setup-java@v4 - with: - distribution: temurin - java-version: 21 - cache: 'sbt' + - uses: ./.github/setup - name: Test run: sbt test @@ -63,12 +48,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Set up JDK - uses: actions/setup-java@v4 - with: - distribution: temurin - java-version: 21 - cache: 'sbt' + - uses: ./.github/setup - uses: actions/setup-node@v4 with: node-version: 20 @@ -87,12 +67,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Set up JDK - uses: actions/setup-java@v4 - with: - distribution: temurin - java-version: 21 - cache: 'sbt' + - uses: ./.github/setup - name: Run stryker run: sbt 'project WeaponRegeX; stryker' env: @@ -112,13 +87,8 @@ jobs: fetch-depth: 0 # Fetch all tags - run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* - - name: Set up JDK - uses: actions/setup-java@v4 - with: - distribution: temurin - java-version: 21 - cache: 'sbt' - run: git fetch --tags + - uses: ./.github/setup - name: Set NPM Env run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc - name: Publish code