Skip to content

Commit 3ee90d3

Browse files
committed
ci: share onnx model between jobs
python and java application merged into same workflow model converted to onnx is also shared between those jobs
1 parent f0b98c8 commit 3ee90d3

File tree

2 files changed

+61
-47
lines changed

2 files changed

+61
-47
lines changed

.github/workflows/java-app.yml

+61-12
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,83 @@
1-
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
2-
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle
3-
4-
name: Java CI with Gradle
1+
# This workflow converts a Hugging Face model to ONNX format, builds a Java application with Gradle,
2+
# and generates and submits a dependency graph for the project.
3+
name: Java application
54

65
on:
76
push:
8-
branches: [ "main" ]
7+
branches: ["main"]
98
pull_request:
10-
branches: [ "main" ]
9+
branches: ["main"]
10+
11+
permissions:
12+
contents: read
1113

1214
jobs:
13-
build:
15+
convert-model-to-onnx:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
- name: Set up Python 3.10
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: "3.10"
24+
- name: Install dependencies
25+
run: |
26+
python -m pip install --upgrade pip
27+
pip install -q transformers[onnx] transformers[sentencepiece] torch
28+
- name: Hugging Face Model to ONNX
29+
run: |
30+
# Convert Hugging Face Model to ONNX
31+
python -m transformers.onnx --opset 16 --atol 0.005 --feature=token-classification --model=xlm-roberta-large-finetuned-conll03-english onnx_model/
32+
33+
# Upload the ONNX model as an artifact
34+
- name: Upload ONNX model
35+
uses: actions/upload-artifact@v4.3.6
36+
with:
37+
# Artifact name
38+
name: onnx_model # default: artifact
39+
# Files to upload
40+
path: onnx_model/
41+
# Behavior if no files found: warn, error, ignore
42+
if-no-files-found: error
43+
# Expiration in days (1-90, 0 for default)
44+
retention-days: 0
45+
# Compression level (0-9, default: 6)
46+
compression-level: 7
47+
# Overwrite existing artifact (default: false)
48+
overwrite: true
49+
50+
# Build Java application with Gradle
51+
build-java:
1452
runs-on: ubuntu-latest
1553
permissions:
1654
contents: read
55+
needs: convert-model-to-onnx
1756

1857
steps:
1958
- uses: actions/checkout@v4
20-
59+
# Set up JDK 17
2160
- name: Set up JDK 17
2261
uses: actions/setup-java@v4
2362
with:
24-
java-version: '17'
25-
distribution: 'temurin'
63+
java-version: "17"
64+
distribution: "temurin"
2665

2766
# Configure Gradle for optimal use in GitHub Actions, including caching of downloaded dependencies.
2867
# See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md
2968
- name: Setup Gradle
3069
uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0
3170

71+
- name: Download ONNX model from Artifact
72+
uses: actions/download-artifact@v4.1.8
73+
with:
74+
name: onnx_model
75+
path: raw-files # path to download the artifact to
76+
run-id: ${{ github.run_id }}
77+
78+
- name: See artifact contents
79+
run: tree raw-files
80+
3281
# This job is responsible for generating and submitting a dependency graph for the project.
3382
# Generates and submits a dependency graph, enabling Dependabot Alerts for all project dependencies.
3483
# See: https://github.com/gradle/actions/blob/main/dependency-submission/README.md
@@ -43,8 +92,8 @@ jobs:
4392
- name: Set up JDK 17
4493
uses: actions/setup-java@v4
4594
with:
46-
java-version: '17'
47-
distribution: 'temurin'
95+
java-version: "17"
96+
distribution: "temurin"
4897

4998
- name: Generate and submit dependency graph
5099
uses: gradle/actions/dependency-submission@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0

.github/workflows/python-app.yml

-35
This file was deleted.

0 commit comments

Comments
 (0)