|
1 | | -name: CI |
2 | | - |
3 | | -on: [push, pull_request] |
| 1 | +name: ci |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - '**' |
| 6 | + workflow_dispatch: |
| 7 | + inputs: |
| 8 | + clean_build: |
| 9 | + description: 'build all' |
| 10 | + required: false |
| 11 | + default: false |
| 12 | +concurrency: |
| 13 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 14 | + cancel-in-progress: ${{ github.ref_name != 'master' }} |
4 | 15 |
|
5 | 16 | jobs: |
6 | | - build: |
7 | | - runs-on: ${{matrix.os}} |
8 | | - strategy: |
9 | | - matrix: |
10 | | - os: ["ubuntu-latest", "macos-latest", "windows-latest"] |
11 | | - |
12 | | - steps: |
13 | | - - uses: actions/checkout@v4 |
14 | | - - uses: olafurpg/setup-scala@v14 |
15 | | - with: |
16 | | - java-version: 8 |
17 | | - - name: Mount caches |
18 | | - uses: actions/cache@v2 |
19 | | - with: |
20 | | - path: | |
21 | | - ~/.sbt |
22 | | - ~/.ivy2/cache |
23 | | - ~/.cache/coursier |
24 | | - key: ${{ runner.os }}-sbt-${{ hashFiles('**/*.sbt') }} |
25 | | - - name: Remove native tests (Windows only) |
26 | | - if: ${{ runner.os == 'Windows' }} |
27 | | - run: | |
28 | | - rm -rf examples/scalapb-crossproject |
29 | | - shell: bash |
30 | | - - name: Compile and test |
31 | | - run: | |
32 | | - sbt test |
33 | | - cd examples |
34 | | - for d in */ ; do cd "$d" && sbt test && cd ../ ; done |
35 | | - shell: bash |
36 | | - - name: Format check |
37 | | - if: ${{ runner.os == 'Linux' }} |
38 | | - run: | |
39 | | - sbt scalafmtCheck test:scalafmtCheck scalafmtSbtCheck |
40 | | - scripted: |
41 | | - runs-on: ${{matrix.os}} |
42 | | - strategy: |
43 | | - fail-fast: false |
44 | | - matrix: |
45 | | - os: ["ubuntu-latest", "macos-latest", "windows-latest"] |
46 | | - scripted-sbt: ["1.2.8", "1.3.13", "project"] |
47 | | - |
48 | | - steps: |
49 | | - - uses: actions/checkout@v4 |
50 | | - - uses: olafurpg/setup-scala@v14 |
51 | | - with: |
52 | | - java-version: 11 |
53 | | - - name: Mount caches |
54 | | - uses: actions/cache@v2 |
55 | | - with: |
56 | | - path: | |
57 | | - ~/.sbt |
58 | | - ~/.ivy2/cache |
59 | | - ~/.cache/coursier |
60 | | - key: ${{ runner.os }}-sbt-${{ hashFiles('**/*.sbt') }} |
61 | | - - name: Compile and run scripted tests with older version |
62 | | - if: ${{ matrix.scripted-sbt != 'project' }} |
63 | | - env: |
64 | | - SCRIPTED_SBT: ${{ matrix.scripted-sbt }} |
65 | | - run: | |
66 | | - sbt "set scriptedSbt := \"$SCRIPTED_SBT\"" scripted |
67 | | - shell: bash |
68 | | - - name: Compile and run scripted tests with project version |
69 | | - if: ${{ matrix.scripted-sbt == 'project' }} |
70 | | - run: | |
71 | | - sbt "set scriptedSbt := sbtVersion.value" scripted |
72 | | - shell: bash |
73 | | - # Single final job for mergify. |
74 | | - ci-passed: |
| 17 | + test: |
75 | 18 | runs-on: ubuntu-latest |
76 | | - needs: [build, scripted] |
| 19 | + timeout-minutes: 25 |
| 20 | + env: |
| 21 | + # define Java options for both official sbt and sbt-extras |
| 22 | + JAVA_OPTS: -XX:MinRAMPercentage=70.0 -XX:MaxRAMPercentage=70.0 -Xss6M -XX:ReservedCodeCacheSize=256M -Dfile.encoding=UTF-8 |
| 23 | + JVM_OPTS: -XX:MinRAMPercentage=70.0 -XX:MaxRAMPercentage=70.0 -Xss6M -XX:ReservedCodeCacheSize=256M -Dfile.encoding=UTF-8 |
77 | 24 | steps: |
78 | | - - run: ':' |
| 25 | + - id: checkout |
| 26 | + uses: actions/checkout@v3 |
| 27 | + with: |
| 28 | + fetch-depth: 100 |
| 29 | + fetch-tags: true |
| 30 | + sparse-checkout-cone-mode: false |
| 31 | + |
| 32 | + # set vars |
| 33 | + - name: set vars |
| 34 | + uses: ./.github/actions/set_vars |
| 35 | + with: |
| 36 | + clean_build: ${{ github.event.inputs.clean_build }} |
| 37 | + |
| 38 | + - name: Setup Scala |
| 39 | + uses: actions/setup-java@v4 |
| 40 | + with: |
| 41 | + java-version: "21" |
| 42 | + distribution: 'temurin' |
| 43 | + |
| 44 | + - name: restore cache |
| 45 | + uses: ./.github/actions/scala_restore_cache |
| 46 | + with: |
| 47 | + clean_build: ${{ github.event.inputs.clean_build }} |
| 48 | + |
| 49 | + - name: Setup M2 Credentials |
| 50 | + run: mkdir -p ~/.m2 && echo ${{secrets.M2_CREDENTIALS}} | base64 -d > ~/.m2/.credentials |
| 51 | + |
| 52 | + - name: set branch |
| 53 | + run: | |
| 54 | + branch="$(echo -n ${{ github.event.ref }} | sed 's#refs/heads/##g; s#/#-#g' | tr '[:upper:]' '[:lower:]')" |
| 55 | + echo "branch=\"${branch}\"" >> $GITHUB_ENV |
| 56 | +
|
| 57 | + - name: set new version |
| 58 | + run: | |
| 59 | + if [[ ${{env.branch}} == "master" ]]; then |
| 60 | + version="$(date +'%Y.%m.%d')-${{github.run_number}}" |
| 61 | + else |
| 62 | + version="$(date +'%Y.%m.%d')-${branch}-${{github.run_number}}" |
| 63 | + fi |
| 64 | + version=$(echo $version | sed 's/"//g') |
| 65 | + echo "version=$version" |
| 66 | + echo "version=$version" >> $GITHUB_ENV |
| 67 | +
|
| 68 | + - run: | |
| 69 | + echo "version in ThisBuild := \"${{env.version}}\"" > version.sbt |
| 70 | +
|
| 71 | + - run: sbt publish |
| 72 | + |
| 73 | + - name: label vcs |
| 74 | + run: git tag $version && git push --tag |
| 75 | + - name: Save Scala Cache |
| 76 | + uses: ./.github/actions/scala_save_cache |
| 77 | + |
0 commit comments