|
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 | 1 |
|
4 |
| -name: Java CI with Gradle |
| 2 | +# This workflow converts a Hugging Face model to ONNX format, builds a Java application with Gradle, |
| 3 | +# and generates and submits a dependency graph for the project. |
| 4 | +name: Java application |
5 | 5 |
|
6 | 6 | on:
|
7 | 7 | push:
|
8 |
| - branches: [ "main", "add-java-workflow" ] |
| 8 | + branches: ["main", "add-java-workflow"] |
9 | 9 | pull_request:
|
10 |
| - branches: [ "main" ] |
| 10 | + branches: ["main"] |
| 11 | + |
| 12 | +permissions: |
| 13 | + contents: read |
11 | 14 |
|
12 | 15 | jobs:
|
13 |
| - build: |
14 |
| - |
| 16 | + convert-model-to-onnx: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@v4 |
| 21 | + - name: Set up Python 3.10 |
| 22 | + uses: actions/setup-python@v5 |
| 23 | + with: |
| 24 | + python-version: "3.10" |
| 25 | + - name: Install dependencies |
| 26 | + run: | |
| 27 | + python -m pip install --upgrade pip |
| 28 | + pip install -q transformers[onnx] transformers[sentencepiece] torch |
| 29 | + - name: Hugging Face Model to ONNX |
| 30 | + run: | |
| 31 | + # Convert Hugging Face Model to ONNX |
| 32 | + python -m transformers.onnx --opset 16 --atol 0.005 --feature=token-classification --model=xlm-roberta-large-finetuned-conll03-english onnx_model/ |
| 33 | +
|
| 34 | + # Upload the ONNX model as an artifact |
| 35 | + - name: Upload ONNX model |
| 36 | + uses: actions/upload-artifact@v4.3.6 |
| 37 | + with: |
| 38 | + # Artifact name |
| 39 | + name: onnx_model # default: artifact |
| 40 | + # Files to upload |
| 41 | + path: onnx_model/ |
| 42 | + # Behavior if no files found: warn, error, ignore |
| 43 | + if-no-files-found: error |
| 44 | + # Expiration in days (1-90, 0 for default) |
| 45 | + retention-days: 0 |
| 46 | + # Compression level (0-9, default: 6) |
| 47 | + compression-level: 7 |
| 48 | + # Overwrite existing artifact (default: false) |
| 49 | + overwrite: true |
| 50 | + |
| 51 | + # Build Java application with Gradle |
| 52 | + build-java: |
15 | 53 | runs-on: ubuntu-latest
|
16 | 54 | permissions:
|
17 | 55 | contents: read
|
| 56 | + needs: convert-model-to-onnx |
18 | 57 |
|
19 | 58 | steps:
|
20 | 59 | - uses: actions/checkout@v4
|
21 |
| - |
| 60 | + # Set up JDK 17 |
22 | 61 | - name: Set up JDK 17
|
23 | 62 | uses: actions/setup-java@v4
|
24 | 63 | with:
|
25 |
| - java-version: '17' |
26 |
| - distribution: 'temurin' |
| 64 | + java-version: "17" |
| 65 | + distribution: "temurin" |
27 | 66 |
|
28 | 67 | # Configure Gradle for optimal use in GitHub Actions, including caching of downloaded dependencies.
|
29 | 68 | # See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md
|
30 | 69 | - name: Setup Gradle
|
31 | 70 | uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0
|
32 |
| - - name: Download a Build Artifact |
| 71 | + |
| 72 | + - name: Download ONNX model from Artifact |
33 | 73 | uses: actions/download-artifact@v4.1.8
|
34 | 74 | with:
|
35 |
| - # Name of the artifact to download. If unspecified, all artifacts for the run are downloaded. |
36 | 75 | name: onnx_model
|
37 |
| - # Destination path. Supports basic tilde expansion. Defaults to $GITHUB_WORKSPACE |
38 |
| - path: raw-files |
39 |
| - # 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. |
40 |
| - # github-token: ${{ secrets.GITHUB_TOKEN }} # optional |
41 |
| - # # 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. |
42 |
| - # repository: # optional, default is ${{ github.repository }} |
43 |
| - # 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. |
44 |
| - run-id: python-app # optional, default is ${{ github.run_id }} |
45 |
| - |
| 76 | + path: raw-files # path to download the artifact to |
| 77 | + run-id: ${{ github.run_id }} |
| 78 | + |
| 79 | + - name: See artifact contents |
| 80 | + run: tree raw-files |
46 | 81 |
|
47 | 82 | # This job is responsible for generating and submitting a dependency graph for the project.
|
48 | 83 | # Generates and submits a dependency graph, enabling Dependabot Alerts for all project dependencies.
|
|
58 | 93 | - name: Set up JDK 17
|
59 | 94 | uses: actions/setup-java@v4
|
60 | 95 | with:
|
61 |
| - java-version: '17' |
62 |
| - distribution: 'temurin' |
| 96 | + java-version: "17" |
| 97 | + distribution: "temurin" |
63 | 98 |
|
64 | 99 | - name: Generate and submit dependency graph
|
65 | 100 | uses: gradle/actions/dependency-submission@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0
|
0 commit comments