From 237e7765676e7d3eded0444bac984de552641fcd Mon Sep 17 00:00:00 2001 From: Eva Lott Date: Fri, 1 Mar 2024 14:12:29 +0000 Subject: [PATCH] made the dev install run the dev container after it's made --- .../actions/install_requirements/action.yml | 22 +++++++++---------- .github/workflows/_container.yml | 2 ++ .github/workflows/_test.yml | 12 +++++----- .github/workflows/ci.yml | 17 +++++++------- 4 files changed, 29 insertions(+), 24 deletions(-) diff --git a/.github/actions/install_requirements/action.yml b/.github/actions/install_requirements/action.yml index 9c8dc2fe..12fad75d 100644 --- a/.github/actions/install_requirements/action.yml +++ b/.github/actions/install_requirements/action.yml @@ -3,31 +3,31 @@ description: Install a version of python then call pip install and report what w inputs: python-version: description: Python version to install, default is from Dockerfile - default: "dev" + default: "dev_container" pip-install: description: Parameters to pass to pip install default: "$([ -f dev-requirements.txt ] && echo '-c dev-requirements.txt') -e .[dev]" + docker-image: + description: The docker image used on a dev install + default: "" runs: using: composite steps: - - name: Get version of python - run: | - PYTHON_VERSION="${{ inputs.python-version }}" - if [ $PYTHON_VERSION == "dev" ]; then - PYTHON_VERSION="3.11" - fi - echo "PYTHON_VERSION=$PYTHON_VERSION" >> "$GITHUB_ENV" - shell: bash - - name: Setup python uses: actions/setup-python@v5 with: - python-version: ${{ env.PYTHON_VERSION }} + python-version: ${{ inputs.python-version }} + if: inputs.python-version != 'dev_container' - name: Install packages run: pip install ${{ inputs.pip-install }} shell: bash + if: inputs.python-version != 'dev_container' + + - name: Run docker container + run: docker run -d --name my-container ${{ inputs.docker-image }} + if: inputs.python-version == 'dev_container' - name: Report what was installed run: pip freeze diff --git a/.github/workflows/_container.yml b/.github/workflows/_container.yml index 4857ee9e..1f0bb774 100644 --- a/.github/workflows/_container.yml +++ b/.github/workflows/_container.yml @@ -54,3 +54,5 @@ jobs: push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} +outputs: + docker-image: ghcr.io/${{ github.repository }}:${{ steps.meta.outputs.tags }} \ No newline at end of file diff --git a/.github/workflows/_test.yml b/.github/workflows/_test.yml index f652d414..c1952c67 100644 --- a/.github/workflows/_test.yml +++ b/.github/workflows/_test.yml @@ -28,22 +28,24 @@ jobs: # Need this to get version number from last tag fetch-depth: 0 - - if: inputs.python-version == 'dev' - name: Install dev versions of python packages + - if: inputs.python-version == 'dev_container' + name: Install dev_container versions of python packages uses: ./.github/actions/install_requirements + with: + docker-image: : ${{ github.event.inputs.docker-image }} - - if: inputs.python-version == 'dev' + - if: inputs.python-version == 'dev_container' name: Write the requirements as an artifact run: pip freeze --exclude-editable > /tmp/dev-requirements.txt - - if: inputs.python-version == 'dev' + - if: inputs.python-version == 'dev_container' name: Upload dev-requirements.txt uses: actions/upload-artifact@v4 with: name: dev-requirements path: /tmp/dev-requirements.txt - - if: inputs.python-version != 'dev' + - if: inputs.python-version != 'dev_container' name: Install latest versions of python packages uses: ./.github/actions/install_requirements with: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f45e2aaa..3c5bbc4e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,16 +23,17 @@ jobs: runs-on: ["ubuntu-latest"] # can add windows-latest, macos-latest python-version: ["3.10", "3.11"] include: - # Include one that runs in the dev environment + # Include one that runs in the dev container environment - runs-on: "ubuntu-latest" - python-version: "dev" + python-version: "dev_container" fail-fast: false - uses: ./.github/workflows/_test.yml - with: - runs-on: ${{ matrix.runs-on }} - python-version: ${{ matrix.python-version }} - secrets: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + steps: + - uses: ./.github/workflows/_test.yml + with: + runs-on: ${{ matrix.runs-on }} + python-version: ${{ matrix.python-version }} + end: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} container: needs: check