51 lines
1.4 KiB
YAML
51 lines
1.4 KiB
YAML
name: test-and-build
|
|
on:
|
|
push:
|
|
branches: [main, master]
|
|
pull_request:
|
|
workflow_dispatch:
|
|
|
|
env:
|
|
IMAGE: harbor.pmagnus.cloud/btcdata-archive/btcdata-archive
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-python@v5
|
|
with:
|
|
python-version: '3.12.12'
|
|
- run: |
|
|
python -m pip install --require-hashes -r requirements-test.lock
|
|
export PYTHONPATH="$PWD/src"
|
|
echo "PYTHONPATH=$PYTHONPATH" >> "$GITHUB_ENV"
|
|
python -m pytest -q tests/unit
|
|
- run: bash scripts/test-integration.sh
|
|
build:
|
|
needs: test
|
|
if: github.event_name != 'pull_request'
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Immutable commit tag
|
|
id: tag
|
|
run: echo "image=$IMAGE:sha-$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
|
|
- uses: docker/setup-buildx-action@v3
|
|
with:
|
|
driver-opts: network=host
|
|
- uses: docker/login-action@v3
|
|
with:
|
|
registry: harbor.pmagnus.cloud
|
|
username: ${{ secrets.HARBOR_ROBOT_USER }}
|
|
password: ${{ secrets.HARBOR_ROBOT_TOKEN }}
|
|
- uses: docker/build-push-action@v6
|
|
id: image
|
|
with:
|
|
context: .
|
|
platforms: linux/amd64
|
|
push: true
|
|
tags: ${{ steps.tag.outputs.image }}
|
|
- name: Deployment reference
|
|
run: echo '${{ env.IMAGE }}@${{ steps.image.outputs.digest }}'
|