build(deps): bump actions/checkout from 6 to 7 in /.github/workflows #227
Workflow file for this run
This file contains hidden or 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
| name: Arca Models CI | |
| # Triggers the workflow on pushes to the 'main' branch, pull requests targeting 'main', | |
| # release creation, and also allows manual triggering via the GitHub Actions UI. | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths-ignore: | |
| - 'README.md' # Ignores README.md in the root directory | |
| pull_request: | |
| branches: | |
| - main | |
| release: | |
| types: [created] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| jobs: | |
| # Runs the dedicated unit tests for schema validation. | |
| # This job executes only after the Nix environment has been successfully set up. | |
| run-unit-tests: | |
| name: Run Unit Tests | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v7 | |
| - name: Install Nix with Flakes Support (for this job) | |
| # Each job in GitHub Actions runs in an isolated environment. | |
| # Therefore, Nix needs to be installed again for this job's context. | |
| uses: cachix/install-nix-action@v31 | |
| with: | |
| extra_nix_config: | | |
| experimental-features = nix-command flakes | |
| - name: Cache Maven packages | |
| uses: actions/cache@v5 | |
| with: | |
| path: ~/.m2/repository | |
| key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-maven- | |
| - name: Execute Specific Schema Validation Tests | |
| # Runs the Maven test command within the Nix development shell. | |
| # This ensures that tests related to 'JsonSchemaValidationTest' are executed | |
| # using the Java and Maven versions specified in your Nix configuration. | |
| run: nix develop --command mvn --settings ci/mvn_settings.xml --batch-mode -Dtest=JsonSchemaValidationTest test | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| GITHUB_ACTOR: ${{ github.actor }} | |
| # Generates Java models from the JSON schemas. | |
| # This job proceeds only if the unit tests have passed successfully. | |
| generate-java-models: | |
| name: Generate Java Models | |
| runs-on: ubuntu-latest | |
| needs: run-unit-tests # Ensures this job only starts after all tests have passed. | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v7 | |
| - name: Install Nix with Flakes Support (for this job) | |
| # Nix needs to be installed for this independent job as well to ensure the environment is ready. | |
| uses: cachix/install-nix-action@v31 | |
| with: | |
| extra_nix_config: | | |
| experimental-features = nix-command flakes | |
| - name: Cache Maven packages | |
| uses: actions/cache@v5 | |
| with: | |
| path: ~/.m2/repository | |
| key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-maven- | |
| - name: Generate Java Classes from JSON Schemas | |
| # Executes the Maven package phase within the Nix development shell. | |
| # This will trigger 'jsonschema2pojo' to generate your Java classes. | |
| # Tests are skipped as they were already run in the 'Run Unit Tests' job. | |
| run: nix develop --command mvn --settings ci/mvn_settings.xml package -DskipTests | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| GITHUB_ACTOR: ${{ github.actor }} | |
| - name: Upload Maven target directory | |
| # This step preserves the compiled Java classes and built JAR from this job | |
| # to be used in the publish-to-github-packages job. | |
| # This is necessary because GitHub Actions jobs run in isolated environments, | |
| # and without this step, the compiled classes would not be available for deployment. | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: maven-target | |
| path: target/ | |
| retention-days: 1 | |
| # Publishes the Java .jar artifacts to GitHub Packages | |
| publish-to-github-packages: | |
| name: Publish to GitHub Packages | |
| runs-on: ubuntu-latest | |
| needs: generate-java-models # Ensures this job only starts after the Java models have been generated | |
| concurrency: | |
| group: publish-github-packages | |
| cancel-in-progress: false | |
| # Only run this job when pushing to the main branch, creating a release, or manually triggered | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch' || github.event_name == 'release' | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v7 | |
| - name: Install Nix with Flakes Support (for this job) | |
| uses: cachix/install-nix-action@v31 | |
| with: | |
| extra_nix_config: | | |
| experimental-features = nix-command flakes | |
| - name: Download Maven target directory | |
| # This step retrieves the compiled Java classes and built JAR from the generate-java-models job | |
| # and places them in the target/ directory of this job's workspace. | |
| # This ensures that the mvn deploy command has access to the complete artifact for deployment, | |
| # solving the issue of empty JARs being deployed due to isolated job environments. | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: maven-target | |
| path: target/ | |
| - name: Cache Maven packages | |
| uses: actions/cache@v5 | |
| with: | |
| path: ~/.m2/repository | |
| key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-maven- | |
| - name: Deploy to GitHub Packages | |
| # Executes the Maven deploy goal within the Nix development shell. | |
| # This will publish the artifact to GitHub Packages. | |
| # The GITHUB_TOKEN is used for authentication. | |
| run: nix develop --command mvn --settings ci/mvn_settings.xml --batch-mode deploy -DskipTests | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| GITHUB_ACTOR: ${{ github.actor }} | |
| # Publishes Python package to TestPyPI (runs in parallel with GitHub Packages) | |
| publish-to-testpypi: | |
| name: Publish to TestPyPI | |
| runs-on: ubuntu-latest | |
| needs: run-unit-tests | |
| # Run this job only on push to main or release events | |
| if: > | |
| (github.event_name == 'push' && github.ref == 'refs/heads/main') | |
| || github.event_name == 'release' | |
| permissions: | |
| contents: write | |
| # No environment variables needed as version is determined by Git tags | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v7 | |
| with: | |
| # Fetch all history including tags for proper versioning | |
| fetch-depth: 0 | |
| fetch-tags: true | |
| - name: Install Nix with Flakes Support | |
| uses: cachix/install-nix-action@v31 | |
| with: | |
| extra_nix_config: | | |
| experimental-features = nix-command flakes | |
| - name: Generate Python Models from Schemas | |
| run: | | |
| # Enter the Nix development shell and run the code generation commands | |
| nix develop --command bash -c ' | |
| # Ensure the output directory exists | |
| mkdir -p src/arca_models/ | |
| # Generate Python models from JSON schemas | |
| echo "Generating Python models from JSON schemas..." | |
| # Execute datamodel-codegen with the following parameters: | |
| # --input-file-type: Specifies the input file type as JSON schema | |
| # --input: Path to the directory containing JSON schema files | |
| # --output: Path where the generated Python models will be saved | |
| # --output-model-type: Specifies the base class for generated models (Pydantic v2) | |
| # --field-constraints: Adds validation based on JSON schema constraints | |
| # --use-schema-description: Uses schema descriptions for class docstrings | |
| # --use-standard-collections: Use standard collections for better compatibility | |
| # --use-generic-container-types: Use generic container types | |
| # --target-python-version: Target Python 3.12 for optimal compatibility | |
| datamodel-codegen \ | |
| --input-file-type jsonschema \ | |
| --input schemas/arca/ \ | |
| --output src/arca_models/ \ | |
| --output-model-type pydantic_v2.BaseModel \ | |
| --field-constraints \ | |
| --use-schema-description \ | |
| --use-standard-collections \ | |
| --use-generic-container-types \ | |
| --target-python-version 3.12 | |
| # List generated files for verification | |
| echo "Generated Python models:" | |
| ls -la src/arca_models/ | |
| ' | |
| - name: Build and Publish to TestPyPI | |
| run: | | |
| # Enter the Nix development shell and run the build and publish commands | |
| nix develop --command bash -c ' | |
| # Install dependencies from lock file | |
| echo "Syncing dependencies from lock file..." | |
| uv sync --frozen | |
| # Build the package using Hatch (version determined by Git tags) | |
| echo "Building package..." | |
| uv build | |
| # Publish to TestPyPI using UV | |
| echo "Publishing to TestPyPI..." | |
| uv publish --index testpypi | |
| ' | |
| env: | |
| # Pass the TestPyPI API token to the environment | |
| UV_PUBLISH_TOKEN: ${{ secrets.TESTPYPI_API_TOKEN }} |