Skip to content

Commit

Permalink
add bash script to get timestamp
Browse files Browse the repository at this point in the history
Signed-off-by: YanxuanLiu <[email protected]>
  • Loading branch information
YanxuanLiu committed Nov 28, 2024
1 parent 04c4c28 commit fcd950c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 17 deletions.
22 changes: 5 additions & 17 deletions .github/workflows/mvn-verify-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,8 @@ jobs:
id: generateCacheKey
run: |
set -x
jniVer=$(mvn help:evaluate -q -pl dist -Dexpression=spark-rapids-jni.version -DforceStdout)
privateVer=$(mvn help:evaluate -q -pl dist -Dexpression=spark-rapids-private.version -DforceStdout)
jniTimestamp=$(curl -s -H "Accept: application/json" \
"https://oss.sonatype.org/service/local/artifact/maven/resolve?r=snapshots&g=com.nvidia&a=spark-rapids-jni&v=${jniVer}&c=&e=jar&wt=json" \
| jq .data.snapshotTimeStamp) || $(date +'%Y-%m-%d')
privateTimestamp=$(curl -s -H "Accept: application/json" \
"https://oss.sonatype.org/service/local/artifact/maven/resolve?r=snapshots&g=com.nvidia&a=rapids-4-spark-private_2.12&v=${privateVer}&c=&e=jar&wt=json" \
| jq .data.snapshotTimeStamp) || $(date +'%Y-%m-%d')
jniTimestamp=$(. .github/workflows/mvn-verify-check/get-artifact-timestamp.sh spark-rapids-jni)
privateTimestamp=$(. .github/workflows/mvn-verify-check/get-artifact-timestamp.sh rapids-4-spark-private_2.12)
cacheKey="${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}-${{ github.event.pull_request.base.ref }}-${jniTimestamp}-${privateTimestamp}"
echo "dailyCacheKey=$cacheKey" | tee $GITHUB_ENV $GITHUB_OUTPUT
- name: Cache local Maven repository
Expand Down Expand Up @@ -173,15 +167,9 @@ jobs:
id: generateCacheKey
run: |
set -x
jniVer=$(mvn help:evaluate -q -pl dist -Dexpression=spark-rapids-jni.version -DforceStdout)
privateVer=$(mvn help:evaluate -q -pl dist -Dexpression=spark-rapids-private.version -DforceStdout)
jniTimestamp=$(curl -s -H "Accept: application/json" \
"https://oss.sonatype.org/service/local/artifact/maven/resolve?r=snapshots&g=com.nvidia&a=spark-rapids-jni&v=${jniVer}&c=&e=jar&wt=json" \
| jq .data.snapshotTimeStamp) || $(date +'%Y-%m-%d')
privateTimestamp=$(curl -s -H "Accept: application/json" \
"https://oss.sonatype.org/service/local/artifact/maven/resolve?r=snapshots&g=com.nvidia&a=rapids-4-spark-private_2.13&v=${privateVer}&c=&e=jar&wt=json" \
| jq .data.snapshotTimeStamp) || $(date +'%Y-%m-%d')
cacheKey="${{ runner.os }}-maven-scala213-${{ hashFiles('**/pom.xml') }}-${{ github.event.pull_request.base.ref }}-${jniTimestamp}-${privateTimestamp}"
jniTimestamp=$(. .github/workflows/mvn-verify-check/get-artifact-timestamp.sh spark-rapids-jni)
privateTimestamp=$(. .github/workflows/mvn-verify-check/get-artifact-timestamp.sh rapids-4-spark-private_2.13)
cacheKey="${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}-${{ github.event.pull_request.base.ref }}-${jniTimestamp}-${privateTimestamp}"
echo "scala213dailyCacheKey=$cacheKey" | tee $GITHUB_ENV $GITHUB_OUTPUT
- name: Cache local Maven repository
id: cache
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/mvn-verify-check/get-artifact-timestamp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

# Copyright (c) 2024, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -e

project=${1:-"spark-rapids-jni"}
base_URL="https://oss.sonatype.org/service/local/artifact/maven/resolve"

if [[ $project == spark-rapids-jni ]]; then
project_version=$(mvn help:evaluate -q -pl dist -Dexpression=spark-rapids-jni.version -DforceStdout)
elif [[ $project == rapids-4-spark-private* ]]; then
project_version=$(mvn help:evaluate -q -pl dist -Dexpression=spark-rapids-private.version -DforceStdout)
fi

TIMESTAMP=$(curl -s -H "Accept: application/json" \
"${base_URL}?r=snapshots&g=com.nvidia&a=${project}&v=${project_version}&c=&e=jar&wt=json" \
| jq .data.snapshotTimeStamp) || $(date +'%Y-%m-%d')

echo $TIMESTAMP

0 comments on commit fcd950c

Please sign in to comment.