|
| 1 | +name: CI (Scala 2.13) |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ "master" ] |
| 6 | + pull_request: |
| 7 | + branches: [ "master" ] |
| 8 | + workflow_dispatch: # enable manual execution |
| 9 | + |
| 10 | +env: |
| 11 | + G8_PARAM_GITHUB_ORG: "octo-org" |
| 12 | + G8_PARAM_REPO_NAME: "simple-scala-cli" |
| 13 | + G8_PARAM_DEFAULT_BRANCH: "master" |
| 14 | + |
| 15 | +concurrency: |
| 16 | + group: ${{ github.ref }} |
| 17 | + cancel-in-progress: true |
| 18 | + |
| 19 | +jobs: |
| 20 | + |
| 21 | + generate-project: |
| 22 | + name: Generate project |
| 23 | + runs-on: ubuntu-latest |
| 24 | + timeout-minutes: 5 |
| 25 | + steps: |
| 26 | + - uses: actions/checkout@v4 |
| 27 | + - name: Generate project |
| 28 | + run: | |
| 29 | + sbt new file://../simple-scala-cli.g8 \ |
| 30 | + --use_scala_3=false \ |
| 31 | + --name="${G8_PARAM_REPO_NAME}" \ |
| 32 | + --github_org="${G8_PARAM_GITHUB_ORG}" \ |
| 33 | + --default_branch="${G8_PARAM_DEFAULT_BRANCH}" |
| 34 | + - name: Cache generated project |
| 35 | + uses: actions/cache@v4 |
| 36 | + with: |
| 37 | + path: ${{ env.G8_PARAM_REPO_NAME }} |
| 38 | + key: ${{ github.sha }} |
| 39 | + |
| 40 | + gh-workflows-check: |
| 41 | + name: GitHub workflows check |
| 42 | + needs: generate-project |
| 43 | + runs-on: ubuntu-latest |
| 44 | + timeout-minutes: 2 |
| 45 | + steps: |
| 46 | + - uses: actions/checkout@v4 |
| 47 | + - name: Get cached generated project |
| 48 | + uses: actions/cache@v4 |
| 49 | + with: |
| 50 | + path: ${{ env.G8_PARAM_REPO_NAME }} |
| 51 | + key: ${{ github.sha }} |
| 52 | + - name: Setup act |
| 53 | + uses: actionsflow/setup-act@v1 |
| 54 | + - name: GitHub workflows check |
| 55 | + env: |
| 56 | + ACT_PLATFORM: "ubuntu-latest=catthehacker/ubuntu:act-latest" |
| 57 | + run: | |
| 58 | + cd "${G8_PARAM_REPO_NAME}" |
| 59 | + ls ".github/workflows" | \ |
| 60 | + xargs -n 1 -I ^ act --dryrun --platform "${ACT_PLATFORM}" -W ".github/workflows/^" |
| 61 | +
|
| 62 | + scalafmt-check: |
| 63 | + name: Scalafmt check |
| 64 | + needs: generate-project |
| 65 | + runs-on: ubuntu-latest |
| 66 | + timeout-minutes: 1 |
| 67 | + steps: |
| 68 | + - name: Get cached generated project |
| 69 | + uses: actions/cache@v4 |
| 70 | + with: |
| 71 | + path: ${{ env.G8_PARAM_REPO_NAME }} |
| 72 | + key: ${{ github.sha }} |
| 73 | + - uses: coursier/cache-action@v6 |
| 74 | + - uses: VirtusLab/scala-cli-setup@v1 |
| 75 | + - name: Scalafmt check |
| 76 | + run: | |
| 77 | + cd "${G8_PARAM_REPO_NAME}" |
| 78 | + scala-cli fmt --check . || ( |
| 79 | + echo "To format code run" |
| 80 | + echo " scala-cli fmt ." |
| 81 | + exit 1 |
| 82 | + ) |
| 83 | +
|
| 84 | + scala-cli-tests: |
| 85 | + name: Run tests |
| 86 | + needs: generate-project |
| 87 | + runs-on: ubuntu-latest |
| 88 | + timeout-minutes: 2 |
| 89 | + steps: |
| 90 | + - name: Get cached generated project |
| 91 | + uses: actions/cache@v4 |
| 92 | + with: |
| 93 | + path: ${{ env.G8_PARAM_REPO_NAME }} |
| 94 | + key: ${{ github.sha }} |
| 95 | + - uses: coursier/cache-action@v6 |
| 96 | + - uses: VirtusLab/scala-cli-setup@v1 |
| 97 | + - name: Run tests |
| 98 | + run: | |
| 99 | + cd "${G8_PARAM_REPO_NAME}" |
| 100 | + scala-cli test . |
| 101 | +
|
| 102 | + upload-generated-project: |
| 103 | + name: Upload generated project |
| 104 | + if: github.ref == 'refs/heads/master' |
| 105 | + needs: [ gh-workflows-check, scalafmt-check, scala-cli-tests ] |
| 106 | + runs-on: ubuntu-latest |
| 107 | + timeout-minutes: 1 |
| 108 | + steps: |
| 109 | + - name: Get cached generated project |
| 110 | + uses: actions/cache@v4 |
| 111 | + with: |
| 112 | + path: ${{ env.G8_PARAM_REPO_NAME }} |
| 113 | + key: ${{ github.sha }} |
| 114 | + - name: Upload generated project |
| 115 | + uses: actions/upload-artifact@v4 |
| 116 | + with: |
| 117 | + name: ${{ env.G8_PARAM_REPO_NAME }}-scala213 |
| 118 | + path: | |
| 119 | + ${{ env.G8_PARAM_REPO_NAME }}/ |
| 120 | + !${{ env.G8_PARAM_REPO_NAME }}/.bsp |
| 121 | + !${{ env.G8_PARAM_REPO_NAME }}/.scala-build |
| 122 | + if-no-files-found: error |
| 123 | + retention-days: 5 |
0 commit comments