Skip to content

Commit

Permalink
ci: Better env check
Browse files Browse the repository at this point in the history
 Please enter the commit message for your changes. Lines starting
  • Loading branch information
frascuchon committed Jul 2, 2023
1 parent a004642 commit c8cd903
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 28 deletions.
10 changes: 0 additions & 10 deletions .github/workflows/build-python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,11 @@ jobs:
build:
name: Build the python package
runs-on: ubuntu-latest
#defaults:
# run:
# shell: bash -l {0}
# Only build the package if we can deploy it as a docker image
env:
IS_DEPLOYABLE: ${{ secrets.AR_DOCKER_USERNAME != '' }}
steps:
- name: Checkout Code 🛎
uses: actions/checkout@v2
- name: Cache pip 👜
uses: actions/cache@v3
if: env.IS_DEPLOYABLE == 'true'
env:
# Increase this value to reset cache if pyproject.toml has not changed
CACHE_NUMBER: 0
Expand All @@ -27,16 +20,13 @@ jobs:
key: ${{ runner.os }}-pip-${{ env.CACHE_NUMBER }}-${{ hashFiles('pyproject.toml') }}
- name: Setup Node.js
uses: actions/setup-node@v2
if: env.IS_DEPLOYABLE == 'true'
with:
node-version: "14"
- name: Build Package 🍟
if: env.IS_DEPLOYABLE == 'true'
run: |
pip install -U build
scripts/build_distribution.sh
- name: Upload package artifact
if: env.IS_DEPLOYABLE == 'true'
uses: actions/upload-artifact@v2
with:
name: python-package
Expand Down
38 changes: 20 additions & 18 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,19 @@ jobs:
name: Check source changes
uses: ./.github/workflows/check-repo-files.yml

deployable_check:
runs-on: ubuntu-latest
needs: check_repo_files
env:
IS_DEPLOYABLE: ${{ secrets.AR_DOCKER_USERNAME != '' && needs.check_repo_files.outputs.buildChanges }}
outputs:
isDeployable: ${{ steps.set_output.outputs.is_deployable }}
steps:
- name: set output
id: set_output
run: |
echo "is_deployable=$IS_DEPLOYABLE" >> $GITHUB_OUTPUT
run_tests:
strategy:
matrix:
Expand All @@ -46,7 +59,7 @@ jobs:
name: Run base tests
uses: ./.github/workflows/run-python-tests.yml
needs: check_repo_files
if: needs.check_repo_files.outputs.pythonChanges && secrets.AR_DOCKER_USERNAME == ''
if: needs.check_repo_files.outputs.pythonChanges
with:
searchEngine: ${{ matrix.searchEngine }}
searchEngineVersion: ${{ matrix.searchEngineVersion }}
Expand All @@ -61,7 +74,7 @@ jobs:
name: Run extra tests (training, monitoring and listeners)
uses: ./.github/workflows/run-python-tests.yml
needs: check_repo_files
if: needs.check_repo_files.outputs.pythonChanges && secrets.AR_DOCKER_USERNAME == ''
if: needs.check_repo_files.outputs.pythonChanges
# continue-on-error: true
with:
pytestArgs: |
Expand All @@ -74,29 +87,26 @@ jobs:
build_python_package:
name: Build Argilla python package
uses: ./.github/workflows/build-python-package.yml
needs: check_repo_files
if: needs.check_repo_files.outputs.buildChanges && secrets.AR_DOCKER_USERNAME == ''
needs: deployable_check
if: needs.deployable_check.outputs.isDeployable
secrets: inherit

deploy_docker:
name: Build docker image
runs-on: ubuntu-latest
needs:
- check_repo_files
- build_python_package
- run_tests
- run_tests_extra
env:
IS_DEPLOYABLE: ${{ secrets.AR_DOCKER_USERNAME != '' }}
if: needs.check_repo_files.outputs.buildChanges
- deployable_check
if: needs.deployable_check.outputs.isDeployable
strategy:
matrix:
include:
- image: argilla/argilla-server
dockerfile: docker/Dockerfile
readme: README.md
platforms: linux/amd64

- image: argilla/argilla-quickstart
dockerfile: docker/quickstart.Dockerfile
readme: docker/quickstart.README.md
Expand All @@ -107,31 +117,25 @@ jobs:
steps:
- name: Checkout Code 🛎
uses: actions/checkout@v2
if: env.IS_DEPLOYABLE == 'true'
- name: Download python package
uses: actions/download-artifact@v2
with:
name: python-package
path: docker/dist
if: env.IS_DEPLOYABLE == 'true'
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
if: env.IS_DEPLOYABLE == 'true'
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
if: env.IS_DEPLOYABLE == 'true'
- name: Docker meta
id: meta
uses: crazy-max/ghaction-docker-meta@v2
with:
images: ${{ matrix.image }}
if: env.IS_DEPLOYABLE == 'true'
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.AR_DOCKER_USERNAME }}
password: ${{ secrets.AR_DOCKER_PASSWORD }}
if: env.IS_DEPLOYABLE == 'true'
- name: Build & push Docker image
uses: docker/build-push-action@v2
with:
Expand All @@ -141,16 +145,14 @@ jobs:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: true
if: env.IS_DEPLOYABLE == 'true'
- name: Docker Hub Description
uses: peter-evans/dockerhub-description@v3
if: github.event_name == 'release' && env.IS_DEPLOYABLE == 'true'
if: github.event_name == 'release'
with:
username: ${{ secrets.AR_DOCKER_USERNAME }}
password: ${{ secrets.AR_DOCKER_PASSWORD }}
repository: ${{ matrix.image }}
readme-filepath: ${{ matrix.readme }}

# This job will upload a Python Package using Twine when a release is created
# For more information see:
# https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
Expand Down

0 comments on commit c8cd903

Please sign in to comment.