From b2c32349136c7780825ff14531dc1a862be42dc2 Mon Sep 17 00:00:00 2001 From: "Joshua A. Anderson" Date: Wed, 19 Jun 2024 14:58:23 -0400 Subject: [PATCH] Refactor CI to use micromamba instead of docker containers. --- .github/workflows/test.yaml | 83 +++++++++++++++++++++++ .github/workflows/test.yml | 127 ------------------------------------ 2 files changed, 83 insertions(+), 127 deletions(-) create mode 100644 .github/workflows/test.yaml delete mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..8443210 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,83 @@ +name: Test + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +on: + pull_request: + + push: + branches: + - "trunk" + - "trunk-major" + + workflow_dispatch: + + schedule: + - cron: '0 18 * * 1' + +jobs: + execute_notebooks: + name: Execute notebooks + runs-on: ubuntu-24.04 + steps: + - name: Checkout + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + with: + path: hoomd + ref: trunk-minor + repository: glotzerlab/hoomd-blue + submodules: true + + - name: Create Python Environment + uses: mamba-org/setup-micromamba@v1 + with: + environment-name: test + environment-file: hoomd/.github/workflows/environments/py312-conda-lock.yml + micromamba-root-path: ${{ github.workspace }}/micromamba + + - name: Configure conda environment variables + run: | + echo "PYTHONPATH=$GITHUB_WORKSPACE/hoomd/build" >> $GITHUB_ENV + echo "CONDA_PREFIX=$MAMBA_ROOT_PREFIX/envs/test" >> $GITHUB_ENV + echo "CMAKE_PREFIX_PATH=$MAMBA_ROOT_PREFIX/envs/test" >> $GITHUB_ENV + echo "$MAMBA_ROOT_PREFIX/envs/test/bin" >> $GITHUB_PATH + + - name: Configure + run: >- + cmake -B hoomd/build -S hoomd -GNinja + -DCMAKE_BUILD_TYPE=Release + -DENABLE_GPU=off + -DENABLE_MPI=off + -DENABLE_TBB=off + -DBUILD_TESTING=off + -DENABLE_LLVM=off + - name: Compile + run: ninja -j $(($(getconf _NPROCESSORS_ONLN) + 2)) + working-directory: hoomd/build + - name: Display hoomd version + run: python3 -c "import hoomd; print(hoomd.version.version, hoomd.version.git_sha1)" + + - name: Checkout notebooks + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + with: + path: notebooks + - name: List notebooks + run: ls **/*.ipynb + working-directory: notebooks + - name: Execute notebooks + run: 'for i in */; do echo "Running notebooks in: $i" && jupyter nbconvert --execute --inplace $i/*.ipynb || exit 1; done' + working-directory: notebooks + + # This check is very basic, but we don't want to use `python -W error` as it will also catch any + # warnings generated inside nbconvert and its dependencies. + - name: Check for warnings + run: | + has_warnings=0 + for file in **/*.ipynb + do + grep Warning $file && echo "::error file=${file}::Has deprecation warnings" && has_warnings=1 + done + exit ${has_warnings} + working-directory: notebooks diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index e6f1595..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,127 +0,0 @@ -name: Test - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -on: - # Trigger on pull requests. - pull_request: - - # Trigger on pushes to the mainline branches. This prevents building commits twice when the pull - # request source branch is in the same repository. - push: - branches: - - "trunk" - - "trunk-major" - - # Trigger on request. - workflow_dispatch: - - # Weekly builds on the trunk branch to check that the examples continue to work with the latest - # development version of HOOMD. - schedule: - - cron: '0 18 * * 1' - -jobs: - start_action_runners: - name: Start action runners - runs-on: ubuntu-latest - steps: - - name: "Use jetstream2-admin/start" - uses: glotzerlab/jetstream2-admin/start@v1.2.5 - with: - OS_APPLICATION_CREDENTIAL_ID: ${{ secrets.OS_APPLICATION_CREDENTIAL_ID }} - OS_APPLICATION_CREDENTIAL_SECRET: ${{ secrets.OS_APPLICATION_CREDENTIAL_SECRET }} - number: 1 - - execute_notebooks: - name: Execute notebooks - runs-on: [self-hosted,jetstream2,CPU] - container: - image: glotzerlab/software:nompi - options: -u 0 - steps: - - name: Clean workspace - run: ( shopt -s dotglob nullglob; rm -rf ./* ) - shell: bash - - # build the HOOMD trunk-minor branch to test the tutorials on the latest version - - name: Checkout - uses: actions/checkout@v4.1.6 - with: - path: hoomd - ref: trunk-major - repository: glotzerlab/hoomd-blue - submodules: true - - name: Make build directory - run: mkdir build - working-directory: hoomd - - name: Configure - run: >- - cmake - -DCMAKE_BUILD_TYPE=Release - -DENABLE_GPU=off - -DENABLE_MPI=off - -DENABLE_TBB=off - -DBUILD_TESTING=off - -DENABLE_LLVM=on - ../ - working-directory: hoomd/build - - name: Compile - run: make -j $(($(getconf _NPROCESSORS_ONLN) + 2)) - working-directory: hoomd/build - - name: Display hoomd version - run: python3 -c "import hoomd; print(hoomd.version.version, hoomd.version.git_sha1)" - env: - PYTHONPATH: ${{ github.workspace }}/hoomd/build - - # clone the tutorials and run them - - name: Checkout - uses: actions/checkout@v4.1.6 - with: - path: notebooks - - name: List notebooks - run: ls **/*.ipynb - working-directory: notebooks - - name: Execute notebooks - run: 'for i in */; do echo "Running notebooks in: $i" && jupyter nbconvert --execute --inplace $i/*.ipynb || exit 1; done' - working-directory: notebooks - env: - PYTHONPATH: ${{ github.workspace }}/hoomd/build - - # This check is very basic, but we don't want to use `python -W error` as it will also catch any - # warnings generated inside nbconvert and its dependencies. - - name: Check for warnings - run: | - has_warnings=0 - for file in **/*.ipynb - do - grep Warning $file && echo "::error file=${file}::Has deprecation warnings" && has_warnings=1 - done - exit ${has_warnings} - working-directory: notebooks - - # notify developers if the scheduled check fails - - name: Slack notification - if: ${{ github.event_name == 'schedule' && (failure() || cancelled()) }} - uses: 8398a7/action-slack@v3.16.2 - with: - status: ${{ job.status }} - fields: workflow,job,message,commit - mention: channel - if_mention: failure,cancelled - channel: '#dev-hoomd-notifications' - username: Github Action - author_name: '' - job_name: Execute notebooks - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - - - name: Clean workspace - run: ( shopt -s dotglob nullglob; rm -rf ./* ) - shell: bash - - - name: Clean HOME - run: ( shopt -s dotglob nullglob; rm -rf $HOME/* ) - shell: bash