test: add unittest #488
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: Build and Push | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: [main] | |
| workflow_dispatch: | |
| inputs: | |
| cache: | |
| description: "Use cache" | |
| required: false | |
| default: true | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| packages: write | |
| jobs: | |
| ci: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Determine Cache Behavior | |
| id: cache | |
| run: | | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
| echo "cache=${{ inputs.cache }}" >> "$GITHUB_OUTPUT" | |
| echo "CACHE=${{ inputs.cache }}" >> "$GITHUB_ENV" | |
| else | |
| echo "cache=true" >> "$GITHUB_OUTPUT" | |
| echo "CACHE=true" >> "$GITHUB_ENV" | |
| fi | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Install devbox | |
| uses: jetify-com/[email protected] | |
| with: | |
| enable-cache: ${{ steps.cache.outputs.cache }} | |
| - name: Set up release please | |
| id: release | |
| uses: googleapis/release-please-action@v4 | |
| with: | |
| token: ${{ secrets.RELEASE_PLEASE_TOKEN }} | |
| config-file: release-please-config.json | |
| manifest-file: .release-please-manifest.json | |
| - name: Set Release PROJECT_VERSION | |
| if: ${{ steps.release.outputs.release_created }} | |
| run: echo "PROJECT_VERSION=v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }}.${{ steps.release.outputs.patch }}" >> $GITHUB_ENV | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Run Tests | |
| run: devbox run -- make test | |
| - name: Build | |
| run: devbox run -- make build | |
| - name: Publish artifacts | |
| if: github.event_name != 'pull_request' | |
| run: make publish | |
| - name: Publish simplified tag artifacts | |
| if: ${{ steps.release.outputs.release_created }} | |
| run: | | |
| PROJECT_VERSION=v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }} make publish | |
| PROJECT_VERSION=v${{ steps.release.outputs.major }} make publish | |
| - name: Upload Github release assets | |
| if: ${{ steps.release.outputs.release_created }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: gh release upload ${{ steps.release.outputs.tag_name }} ./dist/* --clobber | |