diff --git a/.github/workflows/build-python-package.yml b/.github/workflows/build-python-package.yml index b64367c563..393e7ee9de 100644 --- a/.github/workflows/build-python-package.yml +++ b/.github/workflows/build-python-package.yml @@ -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 @@ -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 diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 2b26255571..e07547440a 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -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: @@ -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 }} @@ -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: | @@ -74,21 +87,19 @@ 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: @@ -96,7 +107,6 @@ jobs: dockerfile: docker/Dockerfile readme: README.md platforms: linux/amd64 - - image: argilla/argilla-quickstart dockerfile: docker/quickstart.Dockerfile readme: docker/quickstart.README.md @@ -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: @@ -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