• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1name: CI
2
3on:
4  push:
5    branches:
6      - master
7  pull_request:
8    branches:
9      - master
10
11permissions:
12  contents: read
13
14jobs:
15  test:
16    permissions:
17      actions: write  # for styfle/cancel-workflow-action to cancel/stop running workflows
18      contents: read  # for actions/checkout to fetch code
19    name: "${{ matrix.root-pom }} on JDK ${{ matrix.java }} on ${{ matrix.os }}"
20    strategy:
21      matrix:
22        os: [ ubuntu-latest ]
23        java: [ 8, 11, 17, 21 ]
24        root-pom: [ 'pom.xml', 'android/pom.xml' ]
25        include:
26          - os: windows-latest
27            java: 21
28            root-pom: pom.xml
29    runs-on: ${{ matrix.os }}
30    env:
31      ROOT_POM: ${{ matrix.root-pom }}
32    steps:
33      # Cancel any previous runs for the same branch that are still running.
34      - name: 'Cancel previous runs'
35        uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # 0.12.1
36        with:
37          access_token: ${{ github.token }}
38      - name: 'Check out repository'
39        uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
40      - name: 'Set up JDK ${{ matrix.java }}'
41        uses: actions/setup-java@2dfa2011c5b2a0f1489bf9e433881c92c1631f88 # v4.3.0
42
43        with:
44          java-version: ${{ matrix.java }}
45          distribution: 'zulu'
46          cache: 'maven'
47      - name: 'Install'
48        shell: bash
49        run: ./mvnw -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn install -U -DskipTests=true -f $ROOT_POM
50      - name: 'Test'
51        shell: bash
52        run: ./mvnw -B -P!standard-with-extra-repos verify -U -Dmaven.javadoc.skip=true -f $ROOT_POM
53      - name: 'Print Surefire reports'
54        # Note: Normally a step won't run if the job has failed, but this causes it to
55        if: ${{ failure() }}
56        shell: bash
57        run: ./util/print_surefire_reports.sh
58      - name: 'Integration Test'
59        if: matrix.java == 11
60        shell: bash
61        run: util/gradle_integration_tests.sh
62
63  publish_snapshot:
64    name: 'Publish snapshot'
65    needs: test
66    if: github.event_name == 'push' && github.repository == 'google/guava'
67    runs-on: ubuntu-latest
68    steps:
69      - name: 'Check out repository'
70        uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
71      - name: 'Set up JDK 21'
72        uses: actions/setup-java@2dfa2011c5b2a0f1489bf9e433881c92c1631f88 # v4.3.0
73        with:
74          java-version: 21
75          distribution: 'zulu'
76          server-id: sonatype-nexus-snapshots
77          server-username: CI_DEPLOY_USERNAME
78          server-password: CI_DEPLOY_PASSWORD
79          cache: 'maven'
80      - name: 'Publish'
81        env:
82          CI_DEPLOY_USERNAME: ${{ secrets.CI_DEPLOY_USERNAME }}
83          CI_DEPLOY_PASSWORD: ${{ secrets.CI_DEPLOY_PASSWORD }}
84        run: ./util/deploy_snapshot.sh
85
86  generate_docs:
87    permissions:
88      contents: write
89    name: 'Generate latest docs'
90    needs: test
91    if: github.event_name == 'push' && github.repository == 'google/guava'
92    runs-on: ubuntu-latest
93    steps:
94      - name: 'Check out repository'
95        uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
96      - name: 'Set up JDK 11'
97        uses: actions/setup-java@2dfa2011c5b2a0f1489bf9e433881c92c1631f88 # v4.3.0
98        with:
99          java-version: 11
100          distribution: 'zulu'
101          cache: 'maven'
102      - name: 'Generate latest docs'
103        env:
104          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
105        run: ./util/update_snapshot_docs.sh
106