Skip to content

Add CLI function to snapshot the environment - #10

Open
OleBialas wants to merge 2 commits into
neuromatch:mainfrom
OleBialas:env_snapshot
Open

Add CLI function to snapshot the environment#10
OleBialas wants to merge 2 commits into
neuromatch:mainfrom
OleBialas:env_snapshot

Conversation

@OleBialas

Copy link
Copy Markdown

Added nmaci snapshot-environment which print a snapshot of the current environment.
This can be used in CI to test that the executed notebooks are not accidentally installing their own dependencies.

Intended usage:

        - name: Snapshot Python environment
          run: |
            nmaci snapshot-environment \
              > "$RUNNER_TEMP/environment-before.txt"

        - name: Process notebook
          # Existing notebook execution step
          run: |
            nmaci process-notebooks "${{ matrix.notebook }}" --execute

        - name: Verify Python environment was not modified
          if: always()
          run: |
            nmaci snapshot-environment \
              > "$RUNNER_TEMP/environment-after.txt"

            if ! diff -u \
              "$RUNNER_TEMP/environment-before.txt" \
              "$RUNNER_TEMP/environment-after.txt"
            then
              echo "::error title=Environment modified::${{ matrix.notebook }} changed installed Python packages"
              exit 1
            fi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant