From 917d9c9beda69b0ba648f470cc0c87ca6a49dcc7 Mon Sep 17 00:00:00 2001 From: Chris Rosenthal Date: Mon, 1 Jul 2024 15:36:19 -0700 Subject: [PATCH] Workflow update (#78) * added pip install --requirement since it is was removed from bin/bootstrap.sh * need to build image on latest Dockerfile before running tests * need to build image on latest Dockerfile before running tests * need github sha like this * trying to reorder to see if I can access git * just going to cut the sha manually using cut * loading version from file before install * version file will not be there if run as Github Action * Updating actions versions --- .github/workflows/docker-publish.yml | 6 ++--- .github/workflows/tests.yml | 38 ++++++++++++++++++++++------ Dockerfile | 3 ++- setup.py | 10 +++++--- 4 files changed, 42 insertions(+), 15 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 5bc33c2..e50c863 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -14,17 +14,17 @@ jobs: run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v3 - name: Login to GitHub Container Registry - uses: docker/login-action@v1 + uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v6 with: push: true tags: | diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4f8b930..91ac9b0 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,18 +1,40 @@ name: Run deenurp tests on deenurp image -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] +on: push jobs: - build: + dev_image: + environment: docker_build + runs-on: ubuntu-latest + outputs: + sha_short: ${{ env.sha_short }} + steps: + - + name: Set env + run: echo "sha_short=`echo ${GITHUB_SHA} | cut -c1-7`" >> $GITHUB_ENV + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - + name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - + name: Build and push + uses: docker/build-push-action@v6 + with: + push: true + tags: ghcr.io/fhcrc/deenurp:${{ env.sha_short }} + test: + needs: [dev_image] runs-on: ubuntu-latest container: - image: ghcr.io/fhcrc/deenurp:latest + image: ghcr.io/fhcrc/deenurp:${{ needs.dev_image.outputs.sha_short }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - run: | python3 -m deenurp.test tests/run.sh diff --git a/Dockerfile b/Dockerfile index 24b7b1c..7b3e03a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,7 +17,8 @@ COPY deenurp.py setup.py requirements.txt /usr/local/share/deenurp/ RUN cd /usr/local/share/deenurp/ && \ PYTHON=/usr/local/bin/python3 \ DEENURP=/usr/local/share/deenurp/ \ - bin/bootstrap.sh /usr/local/ + bin/bootstrap.sh /usr/local/ \ + pip install --upgrade --requirement requirements.txt # clean up sources apt packages RUN rm -rf /var/lib/apt/lists/* && \ diff --git a/setup.py b/setup.py index 06016e2..18a76ce 100644 --- a/setup.py +++ b/setup.py @@ -14,8 +14,12 @@ f'|| rm -f {version_file}.tmp'), shell=True, stderr=open(os.devnull, "w")) -# import must follow 'git describe' command above to update version -from deenurp import __version__ +try: + with open(version_file) as f: + version = f.read().strip().lstrip('v').replace( + '-', '+', 1).replace('-', '.') +except Exception as e: + version = '' class CheckVersion(Command): @@ -77,7 +81,7 @@ def run(self): setup( name='deenurp', - version=__version__, + version=version, package_data={'deenurp': ['data/*', 'test/data/*']}, entry_points={ 'console_scripts': {'deenurp = deenurp:main'}},