diff --git a/.github/actions/setup/action.yaml b/.github/actions/setup/action.yaml new file mode 100644 index 000000000..d04826b14 --- /dev/null +++ b/.github/actions/setup/action.yaml @@ -0,0 +1,40 @@ +name: 'Setup OpenWPM env' +description: 'Sets up conda and installs dependencies' +runs: + using: "composite" + steps: +# All of these steps are just setup + - name: Setting MAMBA_PATH + shell: bash + run: echo "MAMBA_PATH=$HOME/mamba" >> $GITHUB_ENV + - name: Setting OPENWPM_MAMBA_PATH + shell: bash + run: echo "OPENWPM_MAMBA_PATH=$MAMBA_PATH/envs/openwpm" >> $GITHUB_ENV + # If the environment.yaml hasn't changed we just reuse the entire conda install + - id: cache + uses: actions/cache@v4 + env: + cache-name: conda-cache + with: + path: ${{ env.MAMBA_PATH }} + key: ${{ env.cache-name }}-${{ hashFiles('environment.yaml') }} + + - name: Install conda + shell: bash + if: ${{ steps.cache.outputs.cache-hit != 'true' }} + run: $GITHUB_WORKSPACE/scripts/install-mamba.sh + + - shell: bash + run: echo "$MAMBA_PATH/bin" >> $GITHUB_PATH + + - name: Install.sh (cache miss) + shell: bash + if: ${{ steps.cache.outputs.cache-hit != 'true' }} + run: $GITHUB_WORKSPACE/install.sh + - name: Install.sh (cache hit) + shell: bash + if: ${{ steps.cache.outputs.cache-hit == 'true' }} + run: $GITHUB_WORKSPACE/install.sh --skip-create + - shell: bash + run: echo "$OPENWPM_MAMBA_PATH/bin" >> $GITHUB_PATH + # Now we have a working OpenWPM environment \ No newline at end of file diff --git a/.github/workflows/run-tests.yaml b/.github/workflows/run-tests.yaml index 0fe8a269e..50ddad820 100644 --- a/.github/workflows/run-tests.yaml +++ b/.github/workflows/run-tests.yaml @@ -13,71 +13,15 @@ jobs: pre-commit: runs-on: ubuntu-latest steps: - # All of these steps are just setup - uses: actions/checkout@v4 - - name: Setting MAMBA_PATH - run: echo "MAMBA_PATH=$HOME/mamba" >> $GITHUB_ENV - - name: Setting OPENWPM_MAMBA_PATH - run: echo "OPENWPM_MAMBA_PATH=$MAMBA_PATH/envs/openwpm" >> $GITHUB_ENV - # If the environment.yaml hasn't changed we just reuse the entire conda install - - id: cache - uses: actions/cache@v4 - env: - cache-name: conda-cache - with: - path: ${{ env.MAMBA_PATH }} - key: ${{ env.cache-name }}-${{ hashFiles('environment.yaml') }} - - - name: Install conda - if: ${{ steps.cache.outputs.cache-hit != 'true' }} - run: $GITHUB_WORKSPACE/scripts/install-mamba.sh - - - run: echo "$MAMBA_PATH/bin" >> $GITHUB_PATH - - - name: Install.sh (cache miss) - if: ${{ steps.cache.outputs.cache-hit != 'true' }} - run: $GITHUB_WORKSPACE/install.sh - - name: Install.sh (cache hit) - if: ${{ steps.cache.outputs.cache-hit == 'true' }} - run: $GITHUB_WORKSPACE/install.sh --skip-create - - run: echo "$OPENWPM_MAMBA_PATH/bin" >> $GITHUB_PATH - # Now we have a working OpenWPM environment - + - uses: ./.github/actions/setup - run: pre-commit run --all demo: runs-on: ubuntu-latest steps: - # All of these steps are just setup - uses: actions/checkout@v4 - - name: Setting MAMBA_PATH - run: echo "MAMBA_PATH=$HOME/mamba" >> $GITHUB_ENV - - name: Setting OPENWPM_MAMBA_PATH - run: echo "OPENWPM_MAMBA_PATH=$MAMBA_PATH/envs/openwpm" >> $GITHUB_ENV - # If the environment.yaml hasn't changed we just reuse the entire conda install - - id: cache - uses: actions/cache@v4 - env: - cache-name: conda-cache - with: - path: ${{ env.MAMBA_PATH }} - key: ${{ env.cache-name }}-${{ hashFiles('environment.yaml') }} - - - name: Install conda - if: ${{ steps.cache.outputs.cache-hit != 'true' }} - run: $GITHUB_WORKSPACE/scripts/install-mamba.sh - - - run: echo "$MAMBA_PATH/bin" >> $GITHUB_PATH - - - name: Install.sh (cache miss) - if: ${{ steps.cache.outputs.cache-hit != 'true' }} - run: $GITHUB_WORKSPACE/install.sh - - name: Install.sh (cache hit) - if: ${{ steps.cache.outputs.cache-hit == 'true' }} - run: $GITHUB_WORKSPACE/install.sh --skip-create - - run: echo "$OPENWPM_MAMBA_PATH/bin" >> $GITHUB_PATH - # Now we have a working OpenWPM environment - + - uses: ./.github/actions/setup - run: python demo.py --headless tests: runs-on: ubuntu-latest @@ -95,47 +39,8 @@ jobs: ] fail-fast: false steps: - # All of these steps are just setup, maybe we should wrap them in an action - uses: actions/checkout@v4 - - name: Cache node modules - uses: actions/cache@v4 - env: - cache-name: cache-node-modules - with: - # npm cache files are stored in `~/.npm` on Linux/macOS - path: ~/.npm - key: ${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} - # Setting env variables that depend on $HOME - - name: Setting MAMBA_PATH - run: echo "MAMBA_PATH=$HOME/mamba" >> $GITHUB_ENV - - name: Setting OPENWPM_MAMBA_PATH - run: echo "OPENWPM_MAMBA_PATH=$MAMBA_PATH/envs/openwpm" >> $GITHUB_ENV - - # If the environment.yaml hasn't changed we just reuse the entire conda install - - id: conda-cache - uses: actions/cache@v4 - env: - cache-name: conda-cache - with: - path: ${{ env.MAMBA_PATH }} - key: ${{ env.cache-name }}-${{ hashFiles('environment.yaml') }} - - - name: Install conda - if: ${{ steps.conda-cache.outputs.cache-hit != 'true' }} - run: $GITHUB_WORKSPACE/scripts/install-mamba.sh - - - run: echo "$MAMBA_PATH/bin" >> $GITHUB_PATH - - - name: Install.sh (cache miss) - if: ${{ steps.conda-cache.outputs.cache-hit != 'true' }} - run: $GITHUB_WORKSPACE/install.sh - - name: Install.sh (cache hit) - if: ${{ steps.conda-cache.outputs.cache-hit == 'true' }} - run: $GITHUB_WORKSPACE/install.sh --skip-create - - - run: echo "$OPENWPM_MAMBA_PATH/bin" >> $GITHUB_PATH - # Now we have a working OpenWPM environment - + - uses: ./.github/actions/setup - run: ./scripts/ci.sh env: DISPLAY: ":99.0"