| name: tests | |
| on: | |
| pull_request: | |
| push: | |
| branches: | |
| - main | |
| permissions: | |
| contents: read | |
| id-token: write | |
| env: | |
| IMAGE_NAME: hhschu/elna | |
| UV_CACHE_DIR: /tmp/.uv-cache | |
| jobs: | |
| ruff-check: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Run ruff check | |
| uses: astral-sh/ruff-action@v3 | |
| ruff-format: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Run ruff format | |
| uses: astral-sh/ruff-action@v3 | |
| with: | |
| args: "format --check --diff" | |
| pyright: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: astral-sh/setup-uv@v6 | |
| with: | |
| enable-cache: true | |
| version: "latest" | |
| python-version: 3.12 | |
| - name: Run type check | |
| run: uv run --frozen --with pyright pyright | |
| build-and-push-image: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ vars.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Extract metadata (tags, labels) for Docker | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.IMAGE_NAME }} | |
| tags: | | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| type=ref,event=tag | |
| type=ref,event=pr | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| push: ${{ github.ref == 'refs/heads/main' }} | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |