|
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 |
5 | 4 |
|
6 | 5 | on:
|
7 | 6 | push:
|
8 |
| - branches: [ "main" ] |
| 7 | + branches: ["main"] |
9 | 8 | pull_request:
|
10 |
| - branches: [ "main" ] |
| 9 | + branches: ["main"] |
| 10 | + |
| 11 | +permissions: |
| 12 | + contents: read |
11 | 13 |
|
12 | 14 | 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: |
14 | 52 | runs-on: ubuntu-latest
|
15 | 53 | permissions:
|
16 | 54 | contents: read
|
| 55 | + needs: convert-model-to-onnx |
17 | 56 |
|
18 | 57 | steps:
|
19 | 58 | - uses: actions/checkout@v4
|
20 |
| - |
| 59 | + # Set up JDK 17 |
21 | 60 | - name: Set up JDK 17
|
22 | 61 | uses: actions/setup-java@v4
|
23 | 62 | with:
|
24 |
| - java-version: '17' |
25 |
| - distribution: 'temurin' |
| 63 | + java-version: "17" |
| 64 | + distribution: "temurin" |
26 | 65 |
|
27 | 66 | # Configure Gradle for optimal use in GitHub Actions, including caching of downloaded dependencies.
|
28 | 67 | # See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md
|
29 | 68 | - name: Setup Gradle
|
30 | 69 | uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0
|
31 | 70 |
|
| 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 | + |
32 | 81 | # This job is responsible for generating and submitting a dependency graph for the project.
|
33 | 82 | # Generates and submits a dependency graph, enabling Dependabot Alerts for all project dependencies.
|
34 | 83 | # See: https://github.com/gradle/actions/blob/main/dependency-submission/README.md
|
|
43 | 92 | - name: Set up JDK 17
|
44 | 93 | uses: actions/setup-java@v4
|
45 | 94 | with:
|
46 |
| - java-version: '17' |
47 |
| - distribution: 'temurin' |
| 95 | + java-version: "17" |
| 96 | + distribution: "temurin" |
48 | 97 |
|
49 | 98 | - name: Generate and submit dependency graph
|
50 | 99 | uses: gradle/actions/dependency-submission@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0
|
0 commit comments