-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
58 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,83 @@ | ||
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle | ||
|
||
name: Java CI with Gradle | ||
# This workflow converts a Hugging Face model to ONNX format, builds a Java application with Gradle, | ||
# and generates and submits a dependency graph for the project. | ||
name: Java application | ||
|
||
on: | ||
push: | ||
branches: [ "main", "add-java-workflow" ] | ||
branches: ["main", "add-java-workflow"] | ||
pull_request: | ||
branches: [ "main" ] | ||
branches: ["main"] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
|
||
convert-model-to-onnx: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python 3.10 | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.10" | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -q transformers[onnx] transformers[sentencepiece] torch | ||
- name: Hugging Face Model to ONNX | ||
run: | | ||
# Convert Hugging Face Model to ONNX | ||
python -m transformers.onnx --opset 16 --atol 0.005 --feature=token-classification --model=xlm-roberta-large-finetuned-conll03-english onnx_model/ | ||
# Upload the ONNX model as an artifact | ||
- name: Upload ONNX model | ||
uses: actions/[email protected] | ||
with: | ||
# Artifact name | ||
name: onnx_model # default: artifact | ||
# Files to upload | ||
path: onnx_model/ | ||
# Behavior if no files found: warn, error, ignore | ||
if-no-files-found: error | ||
# Expiration in days (1-90, 0 for default) | ||
retention-days: 0 | ||
# Compression level (0-9, default: 6) | ||
compression-level: 7 | ||
# Overwrite existing artifact (default: false) | ||
overwrite: true | ||
|
||
# Build Java application with Gradle | ||
build-java: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
needs: convert-model-to-onnx | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
# Set up JDK 17 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
java-version: "17" | ||
distribution: "temurin" | ||
|
||
# Configure Gradle for optimal use in GitHub Actions, including caching of downloaded dependencies. | ||
# See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md | ||
- name: Setup Gradle | ||
uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0 | ||
- name: Download a Build Artifact | ||
|
||
- name: Download ONNX model from Artifact | ||
uses: actions/[email protected] | ||
with: | ||
# Name of the artifact to download. If unspecified, all artifacts for the run are downloaded. | ||
name: onnx_model | ||
# Destination path. Supports basic tilde expansion. Defaults to $GITHUB_WORKSPACE | ||
path: raw-files | ||
# The GitHub token used to authenticate with the GitHub API. This is required when downloading artifacts from a different repository or from a different workflow run. If this is not specified, the action will attempt to download artifacts from the current repository and the current workflow run. | ||
# github-token: ${{ secrets.GITHUB_TOKEN }} # optional | ||
# # The repository owner and the repository name joined together by "/". If github-token is specified, this is the repository that artifacts will be downloaded from. | ||
# repository: # optional, default is ${{ github.repository }} | ||
# The id of the workflow run where the desired download artifact was uploaded from. If github-token is specified, this is the run that artifacts will be downloaded from. | ||
run-id: python-app # optional, default is ${{ github.run_id }} | ||
|
||
path: raw-files # path to download the artifact to | ||
run-id: ${{ github.run_id }} | ||
|
||
- name: See artifact contents | ||
run: tree raw-files | ||
|
||
# This job is responsible for generating and submitting a dependency graph for the project. | ||
# Generates and submits a dependency graph, enabling Dependabot Alerts for all project dependencies. | ||
|
@@ -58,8 +93,8 @@ jobs: | |
- name: Set up JDK 17 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
java-version: "17" | ||
distribution: "temurin" | ||
|
||
- name: Generate and submit dependency graph | ||
uses: gradle/actions/dependency-submission@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0 |