From 7fcb04fd811840a31e30b8457575d4b20b22d9bc Mon Sep 17 00:00:00 2001 From: LukeShirnia Date: Fri, 26 Apr 2024 10:06:30 +0100 Subject: [PATCH] Make actions use docker compose file --- .github/workflows/pytest.yml | 88 ++++++++++++++++++------------------ 1 file changed, 45 insertions(+), 43 deletions(-) diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 8c9ff14..a3714fe 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -10,49 +10,51 @@ env: jobs: - build_and_push: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Login to Docker Hub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKER_HUB_USERNAME }} - password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} - - - name: Pull Docker images (if exists) - run: | - docker-compose config | grep 'image:' | awk '{print $2}' | while read image; do - base_image_name=$(echo $image | awk -F: '{print $1}') - version_tag=$(echo $image | awk -F: '{print $2}') - existing_tag="${{ env.REPOSITORY }}:${base_image_name#*/}" - echo "Trying to pull existing image $existing_tag" - docker pull $existing_tag || true # Continue even if pull fails - done - - - name: Build Docker images - run: | - docker-compose build --pull - - - name: Push Docker images - run: | - docker-compose config | grep 'image:' | awk '{print $2}' | while read image; do - echo "Processing image: $image" - base_image_name=$(echo $image | awk -F: '{print $1}') - version_tag=$(echo $image | awk -F: '{print $2}') - new_tag="${{ env.REPOSITORY }}:${base_image_name#*/}" - echo "Tagging image $image as $new_tag" - docker tag $image $new_tag - docker push $new_tag - done + # Lets not build and push images every time. This can be done manually. Leaving here for reference. + + # build_and_push: + # runs-on: ubuntu-latest + # steps: + # - name: Checkout code + # uses: actions/checkout@v3 + + # - name: Set up Docker Buildx + # uses: docker/setup-buildx-action@v2 + + # - name: Login to Docker Hub + # uses: docker/login-action@v2 + # with: + # username: ${{ secrets.DOCKER_HUB_USERNAME }} + # password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} + + # - name: Pull Docker images (if exists) + # run: | + # docker-compose config | grep 'image:' | awk '{print $2}' | while read image; do + # base_image_name=$(echo $image | awk -F: '{print $1}') + # version_tag=$(echo $image | awk -F: '{print $2}') + # existing_tag="${{ env.REPOSITORY }}:${base_image_name#*/}" + # echo "Trying to pull existing image $existing_tag" + # docker pull $existing_tag || true # Continue even if pull fails + # done + + # - name: Build Docker images + # run: | + # docker-compose build --pull + + # - name: Push Docker images + # run: | + # docker-compose config | grep 'image:' | awk '{print $2}' | while read image; do + # echo "Processing image: $image" + # base_image_name=$(echo $image | awk -F: '{print $1}') + # version_tag=$(echo $image | awk -F: '{print $2}') + # new_tag="${{ env.REPOSITORY }}:${base_image_name#*/}" + # echo "Tagging image $image as $new_tag" + # docker tag $image $new_tag + # docker push $new_tag + # done test-python-versions: - needs: build_and_push + # needs: build_and_push runs-on: ubuntu-latest strategy: matrix: @@ -69,7 +71,7 @@ jobs: pytest -v --ignore=tests/test_system.py test-systems: - needs: build_and_push + # needs: build_and_push runs-on: ubuntu-latest strategy: matrix: @@ -81,7 +83,7 @@ jobs: - name: Setup test command id: setup run: | - if [ "${{ matrix.distro }}" == "osx-pytest" ]; then + if [ "${{ matrix.distro }}" == " ${{ env.REPOSITORY }}:osx-pytest" ]; then echo "::set-output name=command::python -m pytest" else echo "::set-output name=command::pytest"