Skip to content

More CI

More CI #9100

Workflow file for this run

name: nucliadb Train (py)
on:
pull_request:
branches:
- main
push:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
COMPONENT: nucliadb-train
CONTAINER_REGISTRY: europe-west4-docker.pkg.dev/nuclia-internal/nuclia
IMAGE_NAME: nucliadb_train
jobs:
# Job to run tests
tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.12"]
steps:
- name: Checkout the repository
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
- name: Install the package
run: make -C nucliadb/ install-dev
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
workflows:
- 'nucliadb_node/**'
- 'nucliadb_paragraphs[0-9]*/**'
- 'nucliadb_relations[0-9]*/**'
- 'nucliadb_sidecar/**'
- 'nucliadb_texts[0-9]*/**'
- 'nucliadb_vectors/**'
- name: Calc git info
id: git
run: |-
BRANCH=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}
echo "branch=$BRANCH" >> $GITHUB_OUTPUT
- name: Install rust binding for testing
if: steps.filter.outputs.workflows == 'true'
env:
SECRET_KEY: ${{ secrets.RUST_BUILD_SERVER_SECRET }}
COMMIT_HASH: ${{ github.event.pull_request.head.sha || github.sha }}
BRANCH: ${{ steps.git.outputs.branch }}
MATURIN: "true"
ENV: '{"RUSTFLAGS": "--cfg tokio_unstable"}'
run: |
./scripts/download-build.sh && pip install builds/wheels/*_x86_64.whl || (
echo "Failed building from the build server." && make build-node-binding-debug
)
- name: Run tests
uses: nick-fields/retry@v2
with:
max_attempts: 2
retry_on: error
timeout_minutes: 10
command: |
make -C nucliadb/ test-cov-train
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
flags: train
# PR workflows END here
# PUSH workflows contine with deploy activities
build:
name: Build image and push
needs: tests
uses: ./.github/workflows/_build-img-nucliadb.yml
with:
platforms: linux/amd64,linux/arm64
image-name: nucliadb_train
cache-gha-mode: min
secrets:
inherit
if: github.event_name == 'push'
deploy:
name: Deploy Helm chart and trigger internal CI
runs-on: ubuntu-latest
needs: build
if: github.event_name == 'push'
steps:
- name: Generate a token
id: app-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.GHAPP_ID_NUCLIABOT }}
private-key: ${{ secrets.PK_GHAPP_NUCLIABOT }}
owner: nuclia
- name: Checkout repository
uses: actions/checkout@v3
- name: Calculate short sha
id: env-vars
run: |-
HASH=`git rev-parse --short HEAD`
echo "short_sha=$HASH" >> $GITHUB_OUTPUT
- name: Set helm package image
id: version_step
run: |-
sed -i.bak "s#IMAGE_TO_REPLACE#$IMAGE_NAME:${{ steps.env-vars.outputs.short_sha }}#" ./charts/nucliadb_train/values.yaml
sed -i.bak "s#CONTAINER_REGISTRY_TO_REPLACE#$CONTAINER_REGISTRY#" ./charts/nucliadb_train/values.yaml
VERSION=`cat VERSION`
VERSION_SHA=$VERSION+${{ steps.env-vars.outputs.short_sha }}
sed -i.bak "s#99999.99999.99999#$VERSION_SHA#" ./charts/nucliadb_train/Chart.yaml
echo "version_number=$VERSION_SHA" >> $GITHUB_OUTPUT
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Install Helm
uses: azure/setup-helm@v3
with:
version: v3.4.0
- name: Push helm package
run: |-
helm lint charts/nucliadb_train
helm package charts/nucliadb_train
curl --data-binary "@nucliadb_train-${{ steps.version_step.outputs.version_number }}.tgz" ${{ secrets.HELM_CHART_URL }}/api/charts
- name: Repository Dispatch
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ steps.app-token.outputs.token }}
repository: nuclia/nucliadb_deploy
event-type: promote
client-payload: '{"component": "nucliadb_train", "chart-version": "${{ steps.version_step.outputs.version_number }}"}'