add test report & toReviewers page #25
This file contains hidden or 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: Selective Tests with Conda | |
| on: | |
| workflow_dispatch: | |
| pull_request: | |
| push: | |
| branches: | |
| - main | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| selective: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 40 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Free Disk Space (Ubuntu) | |
| uses: jlumbroso/free-disk-space@main | |
| with: | |
| tool-cache: false | |
| android: true | |
| dotnet: true | |
| haskell: true | |
| large-packages: true | |
| docker-images: true | |
| swap-storage: false | |
| - name: Detect changed files | |
| id: changes | |
| uses: tj-actions/changed-files@v41 | |
| - name: Decide test scope | |
| id: decide | |
| run: | | |
| RUN_AUTO="false" | |
| RUN_EVAL="false" | |
| RUN_ALGO="false" | |
| ALGORITHMS="" | |
| echo "${{ steps.changes.outputs.all_changed_files }}" | tr ' ' '\n' > changed.txt | |
| if grep -E -q '^watermark/(auto_watermark|base|auto_config|__init__)\.py$' changed.txt; then | |
| RUN_AUTO="true" | |
| echo "Detected core framework changes." | |
| fi | |
| if grep -E -q '^test/|^evaluation/' changed.txt; then | |
| RUN_EVAL="true" | |
| echo "Detected evaluation/test changes." | |
| fi | |
| ALGOS_FROM_CONFIG=$(awk -F'/' '/^config\/[^\/]+\.json$/ {gsub(/^config\//,"",$1); gsub(/\.json$/,"",$1); print $1}' changed.txt | sort -u) | |
| ALGOS_FROM_DIR=$(awk -F'/' '$1=="watermark" && $2 !~ /\./ {print $2}' changed.txt | sort -u) | |
| ALGORITHMS=$(printf "%s\n%s\n" "$ALGOS_FROM_CONFIG" "$ALGOS_FROM_DIR" | grep -v '^$' | sort -u | paste -sd, -) | |
| if [ -n "$ALGORITHMS" ]; then | |
| RUN_ALGO="true" | |
| fi | |
| if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then | |
| echo "Manual trigger detected. Forcing full test scope." | |
| RUN_AUTO="true" | |
| RUN_EVAL="true" | |
| fi | |
| echo "Run Auto: $RUN_AUTO" | |
| echo "Run Eval: $RUN_EVAL" | |
| echo "Run Algo: $RUN_ALGO" | |
| echo "Detected Algorithms: $ALGORITHMS" | |
| echo "run_auto=$RUN_AUTO" >> $GITHUB_OUTPUT | |
| echo "run_eval=$RUN_EVAL" >> $GITHUB_OUTPUT | |
| echo "run_algo=$RUN_ALGO" >> $GITHUB_OUTPUT | |
| echo "algorithms=$ALGORITHMS" >> $GITHUB_OUTPUT | |
| - name: Setup micromamba | |
| uses: mamba-org/setup-micromamba@v2 | |
| with: | |
| environment-name: markdiffusion | |
| condarc: | | |
| channels: | |
| - conda-forge | |
| channel_priority: strict | |
| create-args: >- | |
| python=3.11 | |
| pip | |
| pyarrow | |
| pandas | |
| numpy<2.0 | |
| cache-environment: true | |
| - name: Install local package and deps | |
| run: | | |
| micromamba run -n markdiffusion conda install -y markdiffusion || echo "Conda package not found, proceeding to pip..." | |
| micromamba run -n markdiffusion python -m pip install -U pip | |
| micromamba run -n markdiffusion pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu | |
| micromamba run -n markdiffusion pip install -e '.[optional]' --no-cache-dir | |
| micromamba run -n markdiffusion pip install qrcode easydict --no-cache-dir | |
| - name: Run evaluation fast tests | |
| if: steps.decide.outputs.run_eval == 'true' | |
| run: | | |
| micromamba run -n markdiffusion pytest -q tests_ci/test_pipelines.py --maxfail=1 --disable-warnings | |
| - name: Run all algorithms (init/interface only) | |
| if: steps.decide.outputs.run_auto == 'true' | |
| run: | | |
| micromamba run -n markdiffusion pytest -q tests_ci/test_watermark_algorithms.py \ | |
| --skip-generation --skip-detection \ | |
| --maxfail=1 --disable-warnings | |
| - name: Run specific algorithms (filtered) | |
| if: steps.decide.outputs.run_algo == 'true' && steps.decide.outputs.run_auto != 'true' | |
| env: | |
| ALGORITHMS: ${{ steps.decide.outputs.algorithms }} | |
| run: | | |
| echo "Algorithms changed: $ALGORITHMS" | |
| micromamba run -n markdiffusion pytest -q tests_ci/test_watermark_algorithms.py \ | |
| --algorithm "$ALGORITHMS" \ | |
| --maxfail=1 --disable-warnings | |
| - name: No tests needed | |
| if: steps.decide.outputs.run_auto == 'false' && steps.decide.outputs.run_eval == 'false' && steps.decide.outputs.run_algo == 'false' | |
| run: echo "No relevant changes detected. Skipping tests." |