initial commit #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Tests | |
on: | |
- push | |
- pull_request | |
jobs: | |
pre_job: | |
# continue-on-error: true # Uncomment once integration is finished | |
runs-on: ubuntu-latest | |
# Map a step output to a job output | |
outputs: | |
should_skip: ${{ steps.skip_check.outputs.should_skip }} | |
steps: | |
- id: skip_check | |
uses: fkirc/skip-duplicate-actions@v5 | |
with: | |
# All of these options are optional, so you can remove them if you are happy with the defaults | |
concurrent_skipping: 'same_content_newer' | |
skip_after_successful_duplicate: 'true' | |
paths_ignore: '["**/README.md", "**/docs/**"]' | |
# do_not_skip: '["pull_request", "workflow_dispatch", "schedule"]' | |
pytest: | |
needs: pre_job | |
if: needs.pre_job.outputs.should_skip != 'true' | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
shell: bash -el {0} # setup-miniconda requires bash | |
steps: | |
- uses: actions/checkout@v4 | |
- run: | | |
echo "python_version=$(python3 scripts/get_python_version.py)" >> "$GITHUB_OUTPUT" | |
pip3 install --user uv maturin | |
id: get-python-version | |
- uses: conda-incubator/setup-miniconda@v3 | |
with: | |
miniforge-version: latest | |
activate-environment: test | |
python-version: ${{ steps.get-python-version.outputs.python_version }} | |
- name: Cache Conda environment | |
id: cache-conda | |
uses: actions/cache@v4 | |
env: | |
cache-name: cache-conda | |
with: | |
path: ~/miniconda3/envs/test | |
key: ${{ runner.os }}-conda-${{ env.cache-name }}-${{ hashFiles('deps/x86_64-unknown-linux-gnu/requirements_dev.txt', 'scripts/install.sh', '.github/workflows/tests.yml', 'rust/**') }} | |
# restore-keys: | | |
# ${{ runner.os }}-conda-${{ env.cache-name }}- | |
# ${{ runner.os }}-conda- | |
# ${{ runner.os }}- | |
- if: steps.cache-conda.outputs.cache-hit == 'true' | |
run: echo 'conda cache hit!' | |
- name: Install dependencies | |
if: steps.cache-conda.outputs.cache-hit != 'true' | |
run: | | |
# python -m pip install --upgrade pip | |
uv pip install -r deps/x86_64-unknown-linux-gnu/requirements_dev.txt | |
bash scripts/install.sh | |
- name: Run pytest | |
run: | | |
set +e # Do not exit shell on pytest failure | |
python3 scripts/hf_download.py | |
out=$(pytest 2> stderr.txt) | |
exit_code=$? | |
err=$(<stderr.txt) | |
# Display the raw output in the step | |
echo "${out}" | |
echo "${err}" | |
# Display the Markdown output in the job summary | |
echo "\`\`\`python" >> $GITHUB_STEP_SUMMARY | |
echo "${out}" >> $GITHUB_STEP_SUMMARY | |
echo "${err}" >> $GITHUB_STEP_SUMMARY | |
if [[ $exit_code -eq 5 ]] | |
then | |
echo | |
echo 'WARNING: No tests were run and it is considered as success' >> $GITHUB_STEP_SUMMARY | |
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY | |
exit 0 | |
else | |
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY | |
# Exit with the exit-code returned by pytest | |
exit ${exit_code} | |
fi | |
cargo-test: | |
needs: pre_job | |
if: needs.pre_job.outputs.should_skip != 'true' | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
shell: bash -el {0} # setup-miniconda requires bash | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Run cargo test | |
run: | | |
set +e # Do not exit shell on failure | |
cd rust | |
out=$(LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu cargo test 2> stderr.txt) | |
exit_code=$? | |
err=$(<stderr.txt) | |
# Display the raw output in the step | |
echo "${out}" | |
echo "${err}" | |
# Display the Markdown output in the job summary | |
echo "\`\`\`python" >> $GITHUB_STEP_SUMMARY | |
echo "${out}" >> $GITHUB_STEP_SUMMARY | |
echo "${err}" >> $GITHUB_STEP_SUMMARY | |
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY | |
# Exit with the exit-code returned by test | |
exit ${exit_code} |