Skip to content

DM-54869: Add option to specify alias for the host name in db-auth #413

DM-54869: Add option to specify alias for the host name in db-auth

DM-54869: Add option to specify alias for the host name in db-auth #413

Workflow file for this run

name: build_and_test
on:
push:
branches:
- main
tags:
- "*"
pull_request:
jobs:
build_and_test:
# Cassandra tests take some time.
timeout-minutes: 30
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11", "3.12", "3.13"]
services:
# Run cassandra from a docker image.
cassandra:
image: cassandra:4.1
ports:
- 9042:9042
options: --health-cmd "cqlsh --debug" --health-interval 10s --health-retries 12
steps:
- uses: actions/checkout@v6
with:
# Need to clone everything for the git tags.
fetch-depth: 0
- uses: conda-incubator/setup-miniconda@v3
with:
python-version: ${{ matrix.python-version }}
channels: conda-forge,defaults
channel-priority: strict
show-channel-urls: true
miniforge-variant: Miniforge3
use-mamba: true
- name: Update pip/wheel infrastructure
shell: bash -l {0}
run: |
conda install -y -q pip wheel
pip install uv
- name: Install dependencies
shell: bash -l {0}
run: |
uv pip install -r requirements.txt
# We have two cores so we can speed up the testing with xdist
- name: Install pytest packages
shell: bash -l {0}
run: |
uv pip install \
pytest!=9.0.0 pytest-xdist pytest-cov
- name: List installed packages
shell: bash -l {0}
run: |
conda list
pip list -v
- name: Build and install
shell: bash -l {0}
run: |
uv pip install -v --no-deps -e .
- name: Run tests
shell: bash -l {0}
run: |
pytest -r a -v -n 3 \
--cov=lsst.dax.apdb --cov=tests --cov-report=xml --cov-report=term --cov-branch \
--junitxml=junit.xml -o junit_family=legacy
- name: Run tests with Cassandra
env:
DAX_APDB_TEST_CASSANDRA_CLUSTER: localhost
shell: bash -l {0}
run: |
pytest -r a -v -n 1 \
--cov=lsst.dax.apdb --cov=tests --cov-report=xml --cov-report=term --cov-branch --cov-append \
--junitxml=junit.xml -o junit_family=legacy \
tests/test_apdbCassandra.py tests/test_apdbCassandraAdmin.py
- name: Upload coverage to codecov
uses: codecov/codecov-action@v6
with:
files: ./coverage.xml
token: ${{ secrets.CODECOV_TOKEN }}
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v6
with:
files: ./coverage.xml
token: ${{ secrets.CODECOV_TOKEN }}
- name: Upload test results to Codecov
if: ${{ !cancelled() }}
uses: codecov/codecov-action@v6
with:
report_type: test_results
token: ${{ secrets.CODECOV_TOKEN }}
check-changes:
outputs:
skip: ${{ steps.check.outputs.skip }}
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Check if weekly changed
id: check
run: |
# Get SHA hashes for all weekly tags
weekly_sha=$(git tag -l 'w.*' | while read tag; do
git rev-list -n 1 "${tag}"
done)
echo "Weekly tag SHA ${weekly_sha}"
# Extract the current tag and its SHA
current_tag=${GITHUB_REF#refs/tags/}
echo "Current tag: ${current_tag}"
current_sha=$(git rev-list -1 "${current_tag}") || echo "no_value"
echo "Current sha: ${current_sha}"
# Count occurrences of the current SHA in the weekly SHA list
n=$(echo "${weekly_sha}" | grep -c "${current_sha}") || echo "0"
echo "Current tag ${current_tag} (${current_sha}) SHA found ${n} time(s)"
# Determine whether to skip the upload based on the count
if [ "${n}" -gt 1 ]; then
echo "Skip upload"
echo "skip=true" >> "${GITHUB_OUTPUT}"
else
echo "Enable upload"
echo "skip=false" >> "${GITHUB_OUTPUT}"
fi
pypi:
name: Upload release to PyPI
runs-on: ubuntu-latest
needs: [build_and_test, check-changes]
permissions:
id-token: write
if: "${{ ! startsWith(github.ref, 'refs/tags/w.') || needs.check-changes.outputs.skip == 'false' }}"
steps:
- uses: actions/checkout@v6
with:
# Need to clone everything to embed the version.
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.13"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade setuptools wheel build
- name: Build and create distribution
run: |
python -m build --skip-dependency-check
- name: Upload
uses: pypa/gh-action-pypi-publish@release/v1