# This is a basic workflow to help you get started with Actions

name: Checkstyle, Findbugs, Doc Check, etc.

on: [pull_request]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: checkout repo
        uses: actions/checkout@v2

      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v1
        with:
          node-version: '10.11.0'

      - name: Cache local Maven repository
        uses: actions/cache@v2
        with:
          path: ~/.m2/repository
          key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
          restore-keys: |
            ${{ runner.os }}-maven-

      - name: Run a one-line script
        run: |
          mkdir -p ~/.m2
          ALLUXIO_DOCKER_NO_TTY=true \
          ALLUXIO_DOCKER_GIT_CLEAN=true \
          ALLUXIO_DOCKER_MVN_RUNTOEND=true \
          ALLUXIO_CHECKSTYLE=true \
          dev/github/run_docker.sh "\"-Dtest=${{ matrix.modules }}\"" -pl tests
        timeout-minutes: 60

      - name: Archive artifacts
        continue-on-error: true
        uses: actions/upload-artifact@v2
        if: always()
        with:
          name: artifact
          path: |
            **/target/artifacts/*
            **/target/logs/*
            log*
          retention-days: 7

# This is a basic workflow to help you get started with Actions

name: Checkstyle, Findbugs, Doc Check, etc.

on:
  pull_request:
  schedule:
    - cron: 0 0 * * *

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: checkout repo
        uses: actions/checkout@v2

      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v1
        with:
          node-version: '10.11.0'

      - name: Cache local Maven repository
        uses: actions/cache@v2
        with:
          path: ~/.m2/repository
          key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
          restore-keys: |
            ${{ runner.os }}-maven-

      - name: Run a one-line script
        run: |
          mkdir -p ~/.m2
          ALLUXIO_DOCKER_NO_TTY=true \
          ALLUXIO_DOCKER_GIT_CLEAN=true \
          ALLUXIO_DOCKER_MVN_RUNTOEND=true \
          ALLUXIO_CHECKSTYLE=true \
          dev/github/run_docker.sh "\"-Dtest=${{ matrix.modules }}\"" -pl tests
        timeout-minutes: 60

      - name: Archive artifacts
        continue-on-error: true
        uses: actions/upload-artifact@v2
        if: always()
        with:
          name: artifact
          path: |
            **/target/artifacts/*
            **/target/logs/*
            log*
          retention-days: 7

Add a GH action to default branch to utilize build cache
Add a GH action to default branch to utilize build cache

Currently, all newly created PRs that run GH actions jobs will download
all of the maven dependencies for the first run of GH actions. This
leads to unnecessary network bandwidth usage and slows down each job by
2-3 minutes. This only affects the _first_ GH action run of each PR
though. Subsequent actions will be able to utilize that PR branch's
cache.

In order for the first GH actions PR run to utilize a cache _on the
first run_, there needs to be a cache created from the default branch of
the repo[[1]]. By running this small checkstyle and findbugs once a day,
it will force any new dependencies to be added to the cache that all new
PRs would then be able to utilize.

[1]:
https://docs.github.com/en/free-pro-team@latest/actions/guides/caching-dependencies-to-speed-up-workflows#restrictions-for-accessing-a-cache

pr-link: Alluxio/alluxio#12473
change-id: cid-a9631ef688ca852d8337a80a759c92b51777668f