-
Notifications
You must be signed in to change notification settings - Fork 5
ci: refactor ci #353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
ci: refactor ci #353
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| name: "Python Package Build" | ||
| description: "Build Python package with uv, test it, and optionally publish" | ||
| author: "Elements Interactive" | ||
|
|
||
| inputs: | ||
| test-package: | ||
| description: "Whether to test the package (both library and CLI)" | ||
| required: false | ||
| default: "false" | ||
| cli-test-command: | ||
| description: "CLI command to test" | ||
| required: false | ||
| default: "" | ||
| publish: | ||
| description: "Whether to publish the package" | ||
| required: false | ||
| default: "false" | ||
| uv-version: | ||
| description: "Version of uv to use" | ||
| required: false | ||
| default: "latest" | ||
|
|
||
| outputs: | ||
| wheel-file: | ||
| description: "Path to the built wheel file" | ||
| value: ${{ steps.build.outputs.wheel-file }} | ||
| dist-path: | ||
| description: "Path to the dist directory" | ||
| value: ${{ steps.build.outputs.dist-path }} | ||
|
|
||
| runs: | ||
| using: "composite" | ||
| steps: | ||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@b75a909f75acd358c2196fb9a5f1299a9a8868a4 # v6.7.0 | ||
| with: | ||
| version: ${{ inputs.uv-version }} | ||
|
|
||
| - name: Build the package | ||
| id: build | ||
| shell: bash | ||
| run: | | ||
| uv build | ||
|
|
||
| # Set outputs | ||
| WHEEL_FILE=$(ls dist/*.whl | head -1) | ||
| echo "wheel-file=$WHEEL_FILE" >> $GITHUB_OUTPUT | ||
| echo "dist-path=dist" >> $GITHUB_OUTPUT | ||
| echo "Built wheel: $WHEEL_FILE" | ||
|
|
||
| - name: Install the built wheel | ||
| shell: bash | ||
| run: | | ||
| uv venv | ||
| uv pip install "${{ steps.build.outputs.wheel-file }}" | ||
|
|
||
| - name: Test package as CLI tool | ||
| if: inputs.test-package == 'true' | ||
| shell: bash | ||
| run: | | ||
| uv pip install "${{ steps.build.outputs.wheel-file }}[cli]" | ||
| uv run ${{ inputs.cli-test-command }} | ||
|
|
||
| - name: Publish package | ||
| if: inputs.publish == 'true' | ||
| shell: bash | ||
| run: | | ||
| uv publish | ||
|
|
||
| branding: | ||
| icon: "package" | ||
| color: "blue" | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| name: Build and Test Docker Image | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: ["main"] | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| should-test-docker-build: | ||
| permissions: | ||
| contents: read | ||
| pull-requests: read | ||
| name: Check if should `test_docker_build` run | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Check out the repo | ||
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | ||
|
|
||
| - name: Check if Dockerfile changed | ||
| uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2 | ||
| id: docker-changes | ||
| with: | ||
| filters: | | ||
| docker: | ||
| - 'Dockerfile' | ||
| - '.dockerignore' | ||
| workflow: | ||
| - ./.github/actions/docker-build/action.yml | ||
| outputs: | ||
| docker: ${{ steps.docker-changes.outputs.docker }} | ||
| workflow: ${{ steps.docker-changes.outputs.workflow }} | ||
|
|
||
| test-docker-build: | ||
| needs: [should-test-docker-build] | ||
| name: Test Docker build ${{ matrix.arch }} | ||
| runs-on: ubuntu-latest | ||
| if: (needs.should-test-docker-build.outputs.workflow == 'true' || needs.should-test-docker-build.outputs.docker == 'true') | ||
| permissions: | ||
| contents: read | ||
| packages: read | ||
| strategy: | ||
| matrix: | ||
| include: | ||
| - arch: amd64 | ||
| platform: linux/amd64 | ||
| image-name: build-amd64 | ||
| needs-qemu: false | ||
| - arch: arm64 | ||
| platform: linux/arm64 | ||
| image-name: build-arm64 | ||
| needs-qemu: true | ||
| steps: | ||
| - name: Check out the repo | ||
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | ||
|
|
||
| - name: Log in to GitHub Container Registry | ||
| uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0 | ||
| with: | ||
| registry: ghcr.io | ||
| username: ${{ github.actor }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Build image | ||
| uses: ./.github/actions/docker-build | ||
| with: | ||
| context: . | ||
| file: ./Dockerfile | ||
| push: false | ||
| load: true | ||
| platforms: ${{ matrix.platform }} | ||
| cache-from: type=registry,ref=ghcr.io/elementsinteractive/twyn:buildcache-${{ matrix.arch }} | ||
| image-name: ${{ matrix.image-name }} | ||
| setup-qemu: ${{ matrix.needs-qemu }} | ||
|
|
||
| - name: Test | ||
| run: | | ||
| docker run --platform ${{ matrix.platform }} --rm ${{ matrix.image-name }}:pr-${{ github.event.pull_request.number }} --version | ||
sdn4z marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| # This workflow builds the package, installs it, and tests basic functionality | ||
|
|
||
| name: Build and Test Python Package | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: ["main"] | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| test-build-package: | ||
| name: Test package build | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
|
|
||
| steps: | ||
| - name: Check out the repo | ||
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | ||
|
|
||
| - name: Test build package | ||
| uses: ./.github/actions/python-package-build | ||
| with: | ||
| test-package: "true" | ||
| uv-version: "0.8.22" | ||
| cli-test-command: "twyn --version" |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.