Skip to content

Automated Release v1.2.5.7 (#5308) #11513

Automated Release v1.2.5.7 (#5308)

Automated Release v1.2.5.7 (#5308) #11513

Workflow file for this run

name: "bazel"
on:
push:
branches: [main]
pull_request:
branches: [main]
merge_group:
branches: [main]
# Cancel any preceding run on the pull request.
concurrency:
group: bazel-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
jobs:
format_bazel_files:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: tools/format-bazel-files.sh
- name: Check formatting diff
run: |
CHANGED_FILES="$(git diff-index --name-only HEAD --)"
if [[ -z "${CHANGED_FILES}" ]]; then
echo "Success: no formatting changes needed."
exit 0
fi
echo "Found formatting changes in the following files:"
echo "${CHANGED_FILES}"
echo ""
echo "Please run \`tools/format-bazel-files.sh\` to apply the changes."
exit 1
build_direct: # Build p4c directly.
needs: format_bazel_files
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Mount bazel cache
uses: actions/cache/restore@v4
with:
path: ~/.cache/bazel
key: ${{ runner.os }}-bazel-direct-${{ hashFiles('**/*.bazel*', '**/*.bzl') }}
restore-keys: |
${{ runner.os }}-bazel-direct-
- name: Save start time
uses: josStorer/get-current-time@v2
id: start-time
with:
format: X
- name: Install Flex and Bison
run: sudo apt install bison flex libfl-dev
- name: Build p4c
run: bazel build //... --verbose_failures
- name: Save end time
if: always()
uses: josStorer/get-current-time@v2
id: end-time
with:
format: X
- name: Calculate build duration
if: always()
run: |
START=${{ steps.start-time.outputs.formattedTime }}
END=${{ steps.end-time.outputs.formattedTime }}
DURATION=$(( END - START ))
echo "duration=$DURATION" | tee "$GITHUB_ENV"
- name: Compress cache
if: always()
run: rm -rf $(bazel info repository_cache)
- name: Save bazel cache
uses: actions/cache/save@v4
if: always() && (github.ref_name == 'main' || env.duration > 180)
with:
path: ~/.cache/bazel
key: ${{ runner.os }}-bazel-direct-${{ hashFiles('**/*.bazel*', '**/*.bzl') }}-${{ github.run_id }}
build_indirect: # Build 3rd party Bazel project depending on p4c as a subproject.
needs: format_bazel_files
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Mount bazel cache
uses: actions/cache/restore@v4
with:
path: ~/.cache/bazel
key: ${{ runner.os }}-bazel-indirect-${{ hashFiles('**/*.bazel*', '**/*.bzl') }}
restore-keys: |
${{ runner.os }}-bazel-indirect-
- name: Save start time
uses: josStorer/get-current-time@v2
id: start-time
with:
format: X
- name: Install Flex and Bison
run: sudo apt install bison flex libfl-dev
- name: Build bazel/example
run: cd ./bazel/example && bazel build //... --verbose_failures
- name: Save end time
if: always()
uses: josStorer/get-current-time@v2
id: end-time
with:
format: X
- name: Calculate build duration
if: always()
run: |
START=${{ steps.start-time.outputs.formattedTime }}
END=${{ steps.end-time.outputs.formattedTime }}
DURATION=$(( END - START ))
echo "duration=$DURATION" | tee "$GITHUB_ENV"
- name: Compress cache
if: always()
run: rm -rf $(bazel info repository_cache)
- name: Save bazel cache
uses: actions/cache/save@v4
if: always() && (github.ref_name == 'main' || env.duration > 180)
with:
path: ~/.cache/bazel
key: ${{ runner.os }}-bazel-indirect-${{ hashFiles('**/*.bazel*', '**/*.bzl') }}-${{ github.run_id }}