Run CTS on PR #97
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: Run CTS on PR | |
on: | |
workflow_run: | |
workflows: ["Build PR"] | |
types: | |
- completed | |
paths-ignore: | |
- '.github/**' | |
- '!.github/workflows/run-cts-pr.yml' | |
- '.gitignore' | |
- '**.md' | |
jobs: | |
runcts: | |
name: Run CTS | |
runs-on: ${{ matrix.config.os }} | |
if: > | |
${{ github.event.workflow_run.event == 'pull_request' && | |
github.event.workflow_run.conclusion == 'success' }} | |
strategy: | |
fail-fast: false | |
matrix: | |
config: | |
# https://github.com/actions/virtual-environments | |
- { os: macOS-13, arch: x64, embed_rf: OFF } | |
- { os: macOS-12, arch: x64, embed_rf: OFF } | |
- { os: ubuntu-22.04, arch: x64, embed_rf: ON } | |
- { os: ubuntu-22.04, arch: x64, embed_rf: OFF } | |
- { os: ubuntu-20.04, arch: x64, embed_rf: OFF } | |
- { os: windows-2022, arch: x64, embed_rf: OFF } | |
- { os: windows-2022, arch: x86, embed_rf: OFF } | |
- { os: windows-2019, arch: x64, embed_rf: OFF } | |
- { os: windows-2019, arch: x86, embed_rf: OFF } | |
steps: | |
- name: Checkout Conformance Test Script | |
uses: actions/checkout@v4 | |
with: | |
submodules: false | |
# The Mono framework on macOS GitHub Runners provides some really old and | |
# conflicting libraries at high precedence, so remove it. | |
- name: Remove Mono Framework (macOS) | |
if: ${{ runner.os == 'macOS' }} | |
shell: bash | |
run: sudo rm -rf /Library/Frameworks/Mono.framework | |
- name: Download install_staging artifact | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
var artifacts = await github.rest.actions.listWorkflowRunArtifacts({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
run_id: ${{github.event.workflow_run.id}}, | |
}); | |
var matchArtifact = artifacts.data.artifacts.filter((artifact) => { | |
return artifact.name == "install_staging-${{ matrix.config.os }}-${{ matrix.config.arch }}-embedded_${{ matrix.config.embed_rf }}" | |
})[0]; | |
var download = await github.rest.actions.downloadArtifact({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
artifact_id: matchArtifact.id, | |
archive_format: 'zip', | |
}); | |
var fs = require('fs'); | |
fs.writeFileSync('install_staging-${{ matrix.config.os }}-${{ matrix.config.arch }}-embedded_${{ matrix.config.embed_rf }}.zip', Buffer.from(download.data)); | |
- name: Unzip install_staging | |
run: | | |
mkdir install_staging | |
mv install_staging-${{ matrix.config.os }}-${{ matrix.config.arch }}-embedded_${{ matrix.config.embed_rf }}.zip install_staging | |
cd install_staging | |
unzip install_staging-${{ matrix.config.os }}-${{ matrix.config.arch }}-embedded_${{ matrix.config.embed_rf }}.zip | |
- name: Show Dependencies (Linux) | |
if: ${{ runner.os == 'Linux' }} | |
shell: bash | |
run: ldd install_staging/nfiq2/bin/nfiq2 | |
- name: Show Dependencies (macOS) | |
if: ${{ runner.os == 'macOS' }} | |
shell: bash | |
run: otool -L install_staging/nfiq2/bin/nfiq2 | |
- name: Install Packages (Linux) | |
if: ${{ runner.os == 'Linux' }} | |
shell: bash | |
run: | | |
sudo apt -y update | |
sudo apt -y install \ | |
libdb++-dev \ | |
libhwloc-dev \ | |
libjbig-dev \ | |
libjpeg-dev \ | |
liblzma-dev \ | |
libopenjp2-7-dev \ | |
libpng-dev \ | |
libsqlite3-dev \ | |
libssl-dev \ | |
libtiff-dev \ | |
libwebp-dev \ | |
libzstd-dev \ | |
zlib1g-dev | |
- name: Install Packages (macOS) | |
if: ${{ runner.os == 'macOS' }} | |
shell: bash | |
run: | | |
HOMEBREW_NO_INSTALL_CLEANUP=1 HOMEBREW_NO_AUTO_UPDATE=1 \ | |
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 brew install \ | |
berkeley-db \ | |
hwloc \ | |
jpeg-turbo \ | |
libpng \ | |
libtiff \ | |
openjpeg \ | |
openssl \ | |
sqlite \ | |
zlib \ | |
zstd | |
- name: Download Conformance Test | |
shell: bash | |
run: curl -o nfiq2_conformance.zip -L ${{ secrets.NFIQ2_CONFORMANCE_DATASET_URL }} | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.x' | |
- name: Set up external model argument (Windows) | |
if: matrix.config.embed_rf == 'OFF' && runner.os == 'Windows' | |
shell: bash | |
run: echo "NFIQ2_CLI_MODEL_ARGUMENT=-m install_staging/nfiq2/bin/nist_plain_tir-ink.txt" >> $GITHUB_ENV | |
- name: Set up external model argument (Linux/macOS) | |
if: matrix.config.embed_rf == 'OFF' && runner.os != 'Windows' | |
shell: bash | |
run: echo "NFIQ2_CLI_MODEL_ARGUMENT=-m install_staging/nfiq2/share/nist_plain_tir-ink.txt" >> $GITHUB_ENV | |
- name: Set up embedded model argument | |
if: ${{ matrix.config.embed_rf == 'ON' }} | |
shell: bash | |
run: echo "NFIQ2_CLI_MODEL_ARGUMENT=" >> $GITHUB_ENV | |
- name: Run Conformance Test (Windows) | |
if: ${{ runner.os == 'Windows' }} | |
shell: bash | |
run: | | |
unzip -q nfiq2_conformance.zip | |
install_staging/nfiq2/bin/nfiq2 ${{ env.NFIQ2_CLI_MODEL_ARGUMENT }} -i nfiq2_conformance/images -a -v -q -o github.csv | |
- name: Run Conformance Test (Linux) | |
if: ${{ runner.os != 'Windows' }} | |
shell: bash | |
run: | | |
unzip -q nfiq2_conformance.zip | |
chmod +x install_staging/nfiq2/bin/nfiq2 | |
install_staging/nfiq2/bin/nfiq2 ${{ env.NFIQ2_CLI_MODEL_ARGUMENT }} -i nfiq2_conformance/images -a -v -q -o github.csv | |
- name: Diff Conformance Test | |
shell: bash | |
run: | | |
python -m pip install pandas==2.1.4 packaging | |
python conformance/diff.py -s conformance/conformance_expected_output.csv github.csv | |
- name: Upload conformance output artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: conformance_output-${{ matrix.config.os }}-${{ matrix.config.arch }} | |
path: github.csv | |
retention-days: 7 | |
if-no-files-found: error | |
overwrite: true | |
- name: Failed the CTS | |
if: ${{ failure() }} | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
var fs = require('fs'); | |
var issue_number = Number(fs.readFileSync('install_staging/pr_number')); | |
await github.rest.issues.createComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: issue_number, | |
body: ':x: Conformance regression test for ${{ matrix.config.os }} (${{ matrix.config.arch }}) failed. Please review the artifacts for this run.' | |
}); | |
comment_on_pr: | |
name: Comment on PR | |
needs: runcts | |
runs-on: ${{ matrix.config.os }} | |
strategy: | |
matrix: | |
config: | |
- { os: ubuntu-22.04, arch: x64 } | |
steps: | |
- name: Download install_staging artifact | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
var artifacts = await github.rest.actions.listWorkflowRunArtifacts({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
run_id: ${{github.event.workflow_run.id}}, | |
}); | |
var matchArtifact = artifacts.data.artifacts.filter((artifact) => { | |
return artifact.name == "install_staging-${{ matrix.config.os }}-${{ matrix.config.arch }}" | |
})[0]; | |
var download = await github.rest.actions.downloadArtifact({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
artifact_id: matchArtifact.id, | |
archive_format: 'zip', | |
}); | |
var fs = require('fs'); | |
fs.writeFileSync('install_staging-${{ matrix.config.os }}-${{ matrix.config.arch }}.zip', Buffer.from(download.data)); | |
- name: Unzip install_staging | |
run: | | |
mkdir install_staging | |
mv install_staging-${{ matrix.config.os }}-${{ matrix.config.arch }}.zip install_staging | |
cd install_staging | |
unzip install_staging-${{ matrix.config.os }}-${{ matrix.config.arch }}.zip | |
- name: Passed the CTS | |
uses: actions/github-script@v7 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
var fs = require('fs'); | |
var issue_number = Number(fs.readFileSync('install_staging/pr_number')); | |
await github.rest.issues.createComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: issue_number, | |
body: ':white_check_mark: Conformance regression test passed on all tested platforms.' | |
}); |