Skip to content

Merge pull request #191 from keboola/fix/SUPPORT-8272-query-string-wi… #232

Merge pull request #191 from keboola/fix/SUPPORT-8272-query-string-wi…

Merge pull request #191 from keboola/fix/SUPPORT-8272-query-string-wi… #232

Workflow file for this run

name: GitHub Actions
on: [ push ]
concurrency: ci-${{ github.ref }} # to avoid tag collisions in the ECR
env:
# Name of the image in the ECR
APP_IMAGE: keboola/generic-extractor
# Developer portal login
KBC_DEVELOPERPORTAL_VENDOR: "keboola"
KBC_DEVELOPERPORTAL_APP: "ex-generic-v2"
KBC_DEVELOPERPORTAL_USERNAME: "keboola+gha_ex_generic_v2"
KBC_DEVELOPERPORTAL_PASSWORD: ${{ secrets.KBC_DEVELOPERPORTAL_PASSWORD }}
# DockerHub login
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
# Test KBC project
KBC_STORAGE_TOKEN: ${{ secrets.KBC_STORAGE_TOKEN }}
KBC_TEST_PROJECT_URL: "https://connection.keboola.com/admin/projects/395/dashboard"
KBC_TEST_PROJECT_CONFIGS: "315853990" # space separated list
jobs:
build:
runs-on: ubuntu-latest
outputs:
app_image_tag: ${{ steps.tag.outputs.app_image_tag }}
is_semantic_tag: ${{ steps.tag.outputs.is_semantic_tag }}
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Print Docker version
run: docker -v
- name: Docker login
if: env.DOCKERHUB_TOKEN
run: docker login --username "$DOCKERHUB_USER" --password "$DOCKERHUB_TOKEN"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: docker-${{ hashFiles('Dockerfile') }}-${{ github.sha }}
restore-keys: |
docker-${{ hashFiles('Dockerfile') }}
- name: Build and push Docker image with cache
run: |
docker buildx build \
--cache-from=type=local,src=/tmp/.buildx-cache \
--cache-to=type=local,dest=/tmp/.buildx-cache \
--output=type=docker \
--tag $APP_IMAGE .
- name: Set image tag
id: tag
run: |
TAG="${GITHUB_REF##*/}"
IS_SEMANTIC_TAG=$(echo "$TAG" | grep -q '^v\?[0-9]\+\.[0-9]\+\.[0-9]\+$' && echo true || echo false)
if [ "$IS_SEMANTIC_TAG" = "false" ]; then
TAG="${TAG}-${GITHUB_RUN_NUMBER}"
fi
echo "Tag = '$TAG', is semantic tag = '$IS_SEMANTIC_TAG'"
echo "::set-output name=app_image_tag::$TAG"
echo "::set-output name=is_semantic_tag::$IS_SEMANTIC_TAG"
- name: Push image to ECR
uses: keboola/action-push-to-ecr@master
with:
vendor: ${{ env.KBC_DEVELOPERPORTAL_VENDOR }}
app_id: ${{ env.KBC_DEVELOPERPORTAL_APP }}
username: ${{ env.KBC_DEVELOPERPORTAL_USERNAME }}
password: ${{ env.KBC_DEVELOPERPORTAL_PASSWORD }}
tag: ${{ steps.tag.outputs.app_image_tag }}
push_latest: ${{ steps.tag.outputs.is_semantic_tag }}
source_image: ${{ env.APP_IMAGE }}
python-lint:
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Build image
working-directory: ./python-sync-actions
run: docker compose build
- name: Run python lint
working-directory: ./python-sync-actions
run: docker compose run dev flake8 . --config=flake8.cfg
tests:
needs:
- build
- python-lint
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Pull image from ECR
uses: keboola/action-pull-from-ecr@master
with:
vendor: ${{ env.KBC_DEVELOPERPORTAL_VENDOR }}
app_id: ${{ env.KBC_DEVELOPERPORTAL_APP }}
username: ${{ env.KBC_DEVELOPERPORTAL_USERNAME }}
password: ${{ env.KBC_DEVELOPERPORTAL_PASSWORD }}
tag: ${{ needs.build.outputs.app_image_tag }}
target_image: ${{ env.APP_IMAGE}}
tag_as_latest: true
- name: Python Tests
run: docker compose run --rm ci python -v -m unittest discover /code/python-sync-actions
- name: Run Python Functional Tests
working-directory: ./python-sync-actions
run: docker compose run test-calls
- name: PHP Tests
run: docker compose run --rm -v $(pwd)/build:/code/build ci
tests-examples:
needs:
- build
- python-lint
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Pull image from ECR
uses: keboola/action-pull-from-ecr@master
with:
vendor: ${{ env.KBC_DEVELOPERPORTAL_VENDOR }}
app_id: ${{ env.KBC_DEVELOPERPORTAL_APP }}
username: ${{ env.KBC_DEVELOPERPORTAL_USERNAME }}
password: ${{ env.KBC_DEVELOPERPORTAL_PASSWORD }}
tag: ${{ needs.build.outputs.app_image_tag }}
target_image: ${{ env.APP_IMAGE}}
tag_as_latest: true
- name: Test examples
run: |
cd doc
./run-samples.sh
tests-in-kbc:
needs:
- build
- python-lint
runs-on: ubuntu-latest
steps:
- name: Run KBC test jobs
if: env.KBC_STORAGE_TOKEN && env.KBC_TEST_PROJECT_CONFIGS
uses: keboola/action-run-configs-parallel@master
with:
token: ${{ env.KBC_STORAGE_TOKEN }}
componentId: ${{ env.KBC_DEVELOPERPORTAL_APP }}
tag: ${{ needs.build.outputs.app_image_tag }}
configs: ${{ env.KBC_TEST_PROJECT_CONFIGS }}
deploy:
needs:
- build
- tests
- tests-examples
- tests-in-kbc
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/') && needs.build.outputs.is_semantic_tag == 'true'
steps:
- name: Set tag in the Developer Portal
uses: keboola/action-set-tag-developer-portal@master
with:
vendor: ${{ env.KBC_DEVELOPERPORTAL_VENDOR }}
app_id: ${{ env.KBC_DEVELOPERPORTAL_APP }}
username: ${{ env.KBC_DEVELOPERPORTAL_USERNAME }}
password: ${{ env.KBC_DEVELOPERPORTAL_PASSWORD }}
tag: ${{ needs.build.outputs.app_image_tag }}