Skip to content

Commit

Permalink
script
Browse files Browse the repository at this point in the history
  • Loading branch information
jbachorik committed Feb 10, 2025
1 parent c3238ab commit 56703b4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 57 deletions.
65 changes: 11 additions & 54 deletions .github/actions/setup_cached_java/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,10 @@ inputs:
description: "The architecture"
required: true
default: "amd64"
github_token:
description: "GitHub Token for triggering workflows"
required: true

runs:
using: composite
steps:
- name: Install GitHub CLI
shell: bash
run: |
if [[ ${{ inputs.arch }} =~ "-musl" ]]; then
set -x
apk update
apk add curl git
git config --global --add safe.directory /__w/java-profiler/java-profiler
GH_VERSION=$(curl -s https://api.github.com/repos/cli/cli/releases/latest | grep '"tag_name":' | cut -d '"' -f 4 | sed 's/v//')
curl -L -o gh.tar.gz "https://github.com/cli/cli/releases/download/v${GH_VERSION}/gh_${GH_VERSION}_linux_amd64.tar.gz"
tar -xzf gh.tar.gz
mv gh_${GH_VERSION}_linux_amd64/bin/gh /usr/local/bin/
rm -rf gh_${GH_VERSION}_linux_amd64 gh.tar.gz
else
sudo apt update
sudo apt install -y gh
fi
- name: Infer Build JDK
shell: bash
id: infer_build_jdk
Expand Down Expand Up @@ -63,42 +42,20 @@ runs:
key: jdk${{ inputs.version }}-${{ inputs.arch }}--${{ hashFiles('.github/workflows/cache_java.yml', '.github/scripts/java_setup.sh') }}
restore-keys: |
jdk${{ inputs.version }}-${{ inputs.arch }}--
- name: Refresh JDK cache
if: steps.cache_jdk.outputs.cache-hit != 'true' || steps.cache_build_jdk.outputs.cache-hit != 'true'
shell: bash
env:
GH_TOKEN: ${{ inputs.github_token }}
run: |
echo "JDK cache miss detected! Triggering refresh workflow..."
gh workflow run cache_java.yml
- name: Wait for JDK cache refresh
- name: JDK cache miss
if: steps.cache_jdk.outputs.cache-hit != 'true' || steps.cache_build_jdk.outputs.cache-hit != 'true'
shell: bash
env:
GH_TOKEN: ${{ inputs.github_token }}
run: |
while gh run list --workflow="cache_java.yml" --status="in_progress" | grep -q cache_java; do
echo "Waiting for JDK cache refresh to complete..."
sleep 10
done
- name: Cache Build JDK [${{ inputs.arch }}] (Retry)
if: steps.cache_build_jdk.outputs.cache-hit != 'true'
uses: actions/cache/restore@v4
with:
path: |
jdks/${{ steps.infer_build_jdk.outputs.build_jdk }}
key: ${{ steps.infer_build_jdk.outputs.build_jdk }}-${{ inputs.arch }}--${{ hashFiles('.github/workflows/cache_java.yml', '.github/scripts/java_setup.sh') }}
restore-keys: |
${{ steps.infer_build_jdk.outputs.build_jdk }}-${{ inputs.arch }}--
- name: Cache JDK ${{ inputs.version }} [${{ inputs.arch }}] (Retry)
if: steps.cache_jdk.outputs.cache-hit != 'true'
uses: actions/cache/restore@v4
with:
path: |
jdks/jdk${{ inputs.version }}
key: jdk${{ inputs.version }}-${{ inputs.arch }}--${{ hashFiles('.github/workflows/cache_java.yml', '.github/scripts/java_setup.sh') }}
restore-keys: |
jdk${{ inputs.version }}-${{ inputs.arch }}--
OWNER=${{ github.repository_owner }}
REPO=${{ github.event.repository.name }}
BRANCH=${{ github.ref_name }}
WORKFLOW="cache_java.yml"
URL="https://github.com/$OWNER/$REPO/actions/workflows/$WORKFLOW"

echo "### ⚠️ JDK Cache Miss Detected" >> $GITHUB_STEP_SUMMARY
echo "🛠️ [Click here and select ${BRANCH} branch to manually refresh the cache](<$URL>)" >> $GITHUB_STEP_SUMMARY
exit 1
- name: Setup Environment
shell: bash
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ on:
permissions:
contents: read
pull-requests: read
actions: write
actions: read

jobs:
check-for-pr:
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/test_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:

permissions:
contents: read
actions: write
actions: read

jobs:
test-linux-glibc-amd64:
Expand Down Expand Up @@ -57,7 +57,6 @@ jobs:
with:
version: ${{ matrix.java_version }}
arch: 'amd64'
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup OS
if: steps.set_enabled.outputs.enabled == 'true'
run: |
Expand Down

0 comments on commit 56703b4

Please sign in to comment.