scalafmt: simplified config #21
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
name: CI (JVM - Scala 2.13) | |
on: | |
push: | |
branches: [ "master" ] | |
pull_request: | |
branches: [ "master" ] | |
workflow_dispatch: # enable manual execution | |
env: | |
G8_PARAM_GITHUB_ORG: "octo-org" | |
G8_PARAM_REPO_NAME: "simple-scala-cli-jvm-scala213" | |
G8_PARAM_DEFAULT_BRANCH: "master" | |
concurrency: | |
group: ${{ github.ref }}-jvm-scala213 | |
cancel-in-progress: true | |
jobs: | |
generate-project: | |
name: Generate project (JVM - Scala 2.13) | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Generate project | |
run: | | |
sbt new file://../simple-scala-cli.g8 \ | |
--use_scala_3=false \ | |
--use_scala_native=false \ | |
--name="${G8_PARAM_REPO_NAME}" \ | |
--github_org="${G8_PARAM_GITHUB_ORG}" \ | |
--default_branch="${G8_PARAM_DEFAULT_BRANCH}" | |
- name: Cache generated project | |
uses: actions/cache@v4 | |
with: | |
path: ${{ env.G8_PARAM_REPO_NAME }} | |
key: ${{ github.sha }} | |
gh-workflows-check: | |
name: GitHub workflows check (JVM - Scala 2.13) | |
needs: generate-project | |
runs-on: ubuntu-latest | |
timeout-minutes: 2 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Get cached generated project | |
uses: actions/cache@v4 | |
with: | |
path: ${{ env.G8_PARAM_REPO_NAME }} | |
key: ${{ github.sha }} | |
- name: Setup act | |
uses: actionsflow/setup-act@v1 | |
- name: GitHub workflows check | |
env: | |
ACT_PLATFORM: "ubuntu-latest=catthehacker/ubuntu:act-latest" | |
run: | | |
cd "${G8_PARAM_REPO_NAME}" | |
ls ".github/workflows" | \ | |
xargs -n 1 -I ^ act --dryrun --platform "${ACT_PLATFORM}" -W ".github/workflows/^" | |
scalafmt-check: | |
name: Scalafmt check (JVM - Scala 2.13) | |
needs: generate-project | |
runs-on: ubuntu-latest | |
timeout-minutes: 1 | |
steps: | |
- name: Get cached generated project | |
uses: actions/cache@v4 | |
with: | |
path: ${{ env.G8_PARAM_REPO_NAME }} | |
key: ${{ github.sha }} | |
- uses: coursier/cache-action@v6 | |
- uses: VirtusLab/scala-cli-setup@v1 | |
- name: Scalafmt check | |
run: | | |
cd "${G8_PARAM_REPO_NAME}" | |
scala-cli fmt --check . || ( | |
echo "To format code run" | |
echo " scala-cli fmt ." | |
exit 1 | |
) | |
scala-cli-tests: | |
name: Run tests (JVM - Scala 2.13) | |
needs: generate-project | |
runs-on: ubuntu-latest | |
timeout-minutes: 2 | |
steps: | |
- name: Get cached generated project | |
uses: actions/cache@v4 | |
with: | |
path: ${{ env.G8_PARAM_REPO_NAME }} | |
key: ${{ github.sha }} | |
- uses: coursier/cache-action@v6 | |
- uses: VirtusLab/scala-cli-setup@v1 | |
- name: Run tests | |
run: | | |
cd "${G8_PARAM_REPO_NAME}" | |
scala-cli test . | |
upload-generated-project: | |
name: Upload generated project (JVM - Scala 2.13) | |
if: github.ref == 'refs/heads/master' | |
needs: [ gh-workflows-check, scalafmt-check, scala-cli-tests ] | |
runs-on: ubuntu-latest | |
timeout-minutes: 1 | |
steps: | |
- name: Get cached generated project | |
uses: actions/cache@v4 | |
with: | |
path: ${{ env.G8_PARAM_REPO_NAME }} | |
key: ${{ github.sha }} | |
- name: Upload generated project | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.G8_PARAM_REPO_NAME }} | |
path: | | |
${{ env.G8_PARAM_REPO_NAME }}/ | |
!${{ env.G8_PARAM_REPO_NAME }}/.bsp | |
!${{ env.G8_PARAM_REPO_NAME }}/.scala-build | |
if-no-files-found: error | |
retention-days: 5 |