Skip to content

Commit

Permalink
new badge publish mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
yhtang committed Sep 6, 2023
1 parent 0f1ffb9 commit 988d51d
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 27 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/_publish_badge_v2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: ~publish test results into a shields.io endpoint json file

on:
workflow_call:
inputs:
BADGE_FILES:
type: string
description: 'Name/wildcard pattern for shields.io endpoint JSON'
required: true
# outputs:
# GIST_ID:
# description: 'Id of the GitHub Gist that hosts all endpoint JSON files'
# value: ${{ jobs.publish.outputs.STATUS }}

jobs:
publish:
runs-on: ubuntu-22.04
# outputs:
# STATUS: ${{ steps.script.outputs.STATUS }}
steps:
- name: Download artifacts specified by input
uses: actions/download-artifact@v3

- name: Update status badge file in gist
uses: actions/github-script@v6
with:
github-token: ${{ secrets.NVJAX_GIST_TOKEN }}
script: |
const fs = require('fs').promises;
const filesInDirectory = await fs.readdir('.');
const matchingFiles = filesInDirectory.filter(
filename => filename.includes(${{ inputs.BADGE_FILES }})
);
const filesToCreate = await Promise.all(
matchingFiles.map(
async filename => {
const content = await fs.readFile(filename, 'utf8');
return [filename, { content }];
}
)
);
const currentDateTime = new Date().toISOString();
const gistDescription =
`Badge endpoint files from Workflow: ${{ github.workflow }}, ` +
`Run ID: ${{ github.run_id }}, ` +
`Repository: ${{ github.repository }}, ` +
`Event: ${{ github.event_name }}, ` +
`Created: ${currentDateTime}`;
gist = await github.rest.gists.create({
description: gistDescription,
public: false,
files: Object.fromEntries(filesToCreate)
});
console.log(gist)
// return gist.data.id;
18 changes: 5 additions & 13 deletions .github/workflows/_sandbox.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,8 @@ jobs:
cat "$f" | jq -r '.summary' | tee -a $GITHUB_STEP_SUMMARY
done
# publish-badge:
# needs: [run-jobs]
# strategy:
# fail-fast: false
# matrix:
# GPU_ARCH: [V100, A100]
# uses: ./.github/workflows/_publish_badge_v2.yaml
# if: always()
# secrets: inherit
# with:
# ENDPOINT_FILENAME: 'jax-unit-test-status-${{ matrix.GPU_ARCH }}.json'
# PUBLISH: false

publish-badge:
needs: [run-jobs]
uses: ./.github/workflows/_publish_badge_v2.yaml
if: always()
secrets: inherit
36 changes: 22 additions & 14 deletions .github/workflows/_test_jax.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,16 @@ on:
description: 'JAX image built by NVIDIA/JAX-Toolbox'
required: true
default: 'ghcr.io/nvidia/jax:latest'
outputs:
ARTIFACTS:
description: 'Name of the unit test artifact for downstream workflows'
value: ${{ jobs.unit-test.outputs.ARTIFACTS }}
ARTIFACT_NAME:
type: string
description: 'Name of the artifact zip file'
required: false
default: 'jax-unit-test-logs'
BADGE_FILENAME:
type: string
description: 'Name of the endpoint JSON file for shields.io badge'
required: false
default: 'jax-unit-test-badge'

jobs:

Expand All @@ -32,9 +38,7 @@ jobs:
# runs-on: [self-hosted, "${{ matrix.GPU_ARCH == 'A100' && format('{0}:{1}', matrix.GPU_ARCH, github.run_id) || matrix.GPU_ARCH }}"]
runs-on: ubuntu-22.04
env:
ARTIFACTS: 'jax-unit-test-logs'
outputs:
ARTIFACTS: ${{ env.ARTIFACTS }}
BADGE_FILENAME_FULL: ${{ inputs.BADGE_FILENAME }}-${{ matrix.GPU_ARCH }}.json
steps:
- name: Print environment variables
run: env
Expand Down Expand Up @@ -78,12 +82,8 @@ jobs:
- name: Generate job summary for unit test
shell: bash -x -e {0}
run: |
pwd
ls -lR
# bring in utility functions
. .github/workflows/_util.sh
source .github/workflows/scripts/to_json.sh
badge_label='${{ matrix.GPU_ARCH }} Unit'
Expand Down Expand Up @@ -112,11 +112,19 @@ jobs:
badge_label badge_color badge_message \
> sitrep.json
schemaVersion=1 \
label="${badge_label}" \
message="${badge_message}" \
color="${badge_color}" \
to_json schemaVersion label message color \
> ${{ env.BADGE_FILENAME_FULL }}
- name: Upload test logs
uses: actions/upload-artifact@v3
with:
name: ${{ env.ARTIFACTS }}-${{ matrix.GPU_ARCH }}
name: ${{ inputs.ARTIFACT_NAME }}-${{ matrix.GPU_ARCH }}
path: |
sitrep.json
test-backend-independent.log
test-gpu.log
sitrep.json
${{ env.BADGE_FILENAME_FULL }}
File renamed without changes.

0 comments on commit 988d51d

Please sign in to comment.