|
| 1 | +# Build the crate, run the tests, and check the code format. |
| 2 | +name: Build and test |
| 3 | + |
| 4 | +on: |
| 5 | + push: |
| 6 | + pull_request: |
| 7 | + |
| 8 | +env: |
| 9 | + CARGO_TERM_COLOR: always |
| 10 | + RUST_BACKTRACE: 1 |
| 11 | + |
| 12 | +jobs: |
| 13 | + clippy_and_format: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v2 |
| 17 | + |
| 18 | + - uses: actions-rs/clippy-check@v1 |
| 19 | + continue-on-error: true |
| 20 | + with: |
| 21 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 22 | + # we can't yet use all-features, as it depends on nightly |
| 23 | + # args: --all-features |
| 24 | + - run: cargo fmt -- --check |
| 25 | + |
| 26 | + build_and_test: |
| 27 | + runs-on: ubuntu-latest |
| 28 | + steps: |
| 29 | + - uses: actions/checkout@v3 |
| 30 | + - run: cargo test |
| 31 | + - name: Build Docker image |
| 32 | + run: docker build -t terminusdb-semantic-indexer . |
| 33 | + |
| 34 | + build-and-push-image: |
| 35 | + runs-on: ubuntu-latest |
| 36 | + needs: [clippy_and_format, build_and_test] |
| 37 | + if: startsWith(github.ref, 'refs/tags/v') |
| 38 | + permissions: |
| 39 | + contents: read |
| 40 | + packages: write |
| 41 | + env: |
| 42 | + REGISTRY: ghcr.io |
| 43 | + IMAGE_NAME: ${{ github.repository }} |
| 44 | + |
| 45 | + steps: |
| 46 | + - name: Checkout repository |
| 47 | + uses: actions/checkout@v3 |
| 48 | + |
| 49 | + - name: Log in to the Container registry |
| 50 | + uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 |
| 51 | + with: |
| 52 | + registry: ${{ env.REGISTRY }} |
| 53 | + username: ${{ github.actor }} |
| 54 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 55 | + |
| 56 | + - name: Extract metadata (tags, labels) for Docker |
| 57 | + id: meta |
| 58 | + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 |
| 59 | + with: |
| 60 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 61 | + |
| 62 | + - name: Build and push Docker image |
| 63 | + uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 |
| 64 | + with: |
| 65 | + context: . |
| 66 | + push: true |
| 67 | + tags: ${{ steps.meta.outputs.tags }} |
| 68 | + labels: ${{ steps.meta.outputs.labels }} |
0 commit comments