Skip to content

Commit 6a1fe86

Browse files
Fix workflows
1 parent 999cff3 commit 6a1fe86

File tree

5 files changed

+96
-11
lines changed

5 files changed

+96
-11
lines changed

.github/actions/setup-build/action.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ runs:
2424
java-version: 21
2525
distribution: 'zulu'
2626
cache: ${{ inputs.sbt == 'true' && 'sbt' || '' }}
27+
- name: Get JFrog OIDC token
28+
shell: bash
29+
run: .github/scripts/get-jfrog-token.sh
30+
- name: Fix Mill Bootstrap Script
31+
shell: bash
32+
run: .github/scripts/fix-build-config.sh
2733
- name: Set up sbt
2834
if: inputs.sbt == 'true'
2935
uses: sbt/setup-sbt@508b753e53cb6095967669e0911487d2b9bc9f41 # 1.1.22
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
JFROG_HOSTNAME="databricks.jfrog.io"
5+
JFROG_REALM="Artifactory Realm"
6+
JFROG_USERNAME="gha-service-account"
7+
JFROG_URL="https://${JFROG_HOSTNAME}/artifactory/db-maven/"
8+
9+
# Configure sbt repositories
10+
mkdir -p ~/.sbt
11+
cat > ~/.sbt/repositories << 'EOF'
12+
[repositories]
13+
local
14+
databricks-jfrog: ${JFROG_URL}
15+
EOF
16+
17+
# Configure sbt credentials
18+
cat > ~/.sbt/.credentials << EOF
19+
realm=${JFROG_REALM}
20+
host=${JFROG_HOSTNAME}
21+
user=${JFROG_USERNAME}
22+
password=${JFROG_ACCESS_TOKEN}
23+
EOF
24+
25+
# Configure global.sbt to load credentials
26+
mkdir -p ~/.sbt/1.0
27+
cat > ~/.sbt/1.0/global.sbt << 'EOF'
28+
def sbtCredentialsFile = file(sys.props("user.home")) / ".sbt" / ".credentials"
29+
credentials ++= {
30+
if (sbtCredentialsFile.exists()) List(Credentials(sbtCredentialsFile))
31+
else Nil
32+
}
33+
EOF
34+
35+
36+
mkdir -p ~/.config/coursier
37+
{
38+
echo "jfrog.host=${JFROG_HOSTNAME}"
39+
echo "jfrog.realm=${JFROG_REALM}"
40+
echo "jfrog.username=${JFROG_USERNAME}"
41+
echo "jfrog.password=${JFROG_ACCESS_TOKEN}"
42+
} > ~/.config/coursier/credentials.properties
43+
44+
echo "COURSIER_REPOSITORIES=${JFROG_URL}" >> "$GITHUB_ENV"
45+
sed -i "s|https://repo1.maven.org/maven2|https://${JFROG_USERNAME}:${JFROG_ACCESS_TOKEN}@${JFROG_URL:8}|g" ./mill

.github/scripts/get-jfrog-token.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# Exchange a GitHub Actions OIDC token for a JFrog access token and
5+
# write JFROG_ACCESS_TOKEN to $GITHUB_ENV so subsequent steps can use it.
6+
7+
# Get GitHub OIDC ID token
8+
ID_TOKEN=$(curl -sLS \
9+
-H "User-Agent: actions/oidc-client" \
10+
-H "Authorization: Bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
11+
"${ACTIONS_ID_TOKEN_REQUEST_URL}&audience=jfrog-github" | jq .value | tr -d '"')
12+
echo "::add-mask::${ID_TOKEN}"
13+
14+
# Exchange for JFrog access token (note: id_token with underscore, not hyphen)
15+
ACCESS_TOKEN=$(curl -sLS -XPOST -H "Content-Type: application/json" \
16+
"https://databricks.jfrog.io/access/api/v1/oidc/token" \
17+
-d "{\"grant_type\": \"urn:ietf:params:oauth:grant-type:token-exchange\", \"subject_token_type\":\"urn:ietf:params:oauth:token-type:id_token\", \"subject_token\": \"${ID_TOKEN}\", \"provider_name\": \"github-actions\"}" | jq .access_token | tr -d '"')
18+
echo "::add-mask::${ACCESS_TOKEN}"
19+
20+
if [ -z "$ACCESS_TOKEN" ] || [ "$ACCESS_TOKEN" = "null" ]; then
21+
echo "FAIL: Could not extract JFrog access token"
22+
exit 1
23+
fi
24+
25+
echo "JFROG_ACCESS_TOKEN=${ACCESS_TOKEN}" >> "$GITHUB_ENV"
26+
27+
echo "JFrog OIDC token obtained successfully"

.github/workflows/pr-build.yaml

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,16 @@ on:
44
pull_request:
55
branches: [ master ]
66

7-
permissions: {}
7+
permissions:
8+
contents: read
9+
id-token: write
810

911
jobs:
1012
build-jvm:
11-
runs-on: linux-ubuntu-latest-hardened
13+
runs-on:
14+
group: databricks-protected-runner-group
15+
labels: linux-ubuntu-latest
16+
timeout-minutes: 20
1217
name: Sjsonnet jvm build
1318
steps:
1419
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
@@ -19,28 +24,31 @@ jobs:
1924
- name: Check Formatting
2025
run: ./mill "_.jvm[_].__.checkFormat"
2126
- name: Run mill tests
22-
timeout-minutes: 15
2327
run: ./mill "_.jvm[_].__.test"
2428
- name: Run sbt tests
25-
timeout-minutes: 15
2629
run: sbt test
2730
build-graal:
28-
runs-on: linux-ubuntu-latest-hardened
31+
runs-on:
32+
group: databricks-protected-runner-group
33+
labels: linux-ubuntu-latest
34+
timeout-minutes: 20
2935
name: Sjsonnet Graal Native build
3036
steps:
3137
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
3238
- uses: ./.github/actions/setup-build
3339
with:
3440
coursier-cache: 'true'
3541
- name: Run Native Image Test Suites
36-
timeout-minutes: 15
3742
run: sjsonnet/test/graalvm/run_test_suites.py
3843
build-other:
39-
runs-on: linux-ubuntu-latest-hardened
44+
runs-on:
45+
group: databricks-protected-runner-group
46+
labels: linux-ubuntu-latest
47+
timeout-minutes: 20
4048
strategy:
4149
fail-fast: false
4250
matrix:
43-
lang: ['js', 'wasm', 'native']
51+
lang: ['js', 'wasm']
4452
name: Sjsonnet ${{ matrix.lang }} build
4553
steps:
4654
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
@@ -52,5 +60,4 @@ jobs:
5260
- name: Check Formatting
5361
run: ./mill _.${{ matrix.lang }}[_].__.checkFormat
5462
- name: Run mill tests for ${{ matrix.lang }}
55-
timeout-minutes: 15
5663
run: ./mill _.${{ matrix.lang }}[_].__.test

build.mill

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//| mill-version: 1.1.2
1+
//| mill-version: 1.1.5
22
//| mill-jvm-version: zulu:21
33
//| mvnDeps:
44
//| - com.lihaoyi::mill-contrib-jmh:$MILL_VERSION
@@ -53,7 +53,7 @@ trait SjsonnetCrossModule extends CrossScalaModule with ScalafmtModule {
5353
def mvnDeps = Seq(
5454
mvn"com.lihaoyi::fastparse::3.1.1",
5555
mvn"com.lihaoyi::pprint::0.9.6",
56-
mvn"com.lihaoyi::ujson::4.4.2",
56+
mvn"com.lihaoyi::ujson::4.4.3",
5757
mvn"com.lihaoyi::scalatags::0.13.1",
5858
mvn"org.scala-lang.modules::scala-collection-compat::2.14.0"
5959
)

0 commit comments

Comments
 (0)