Skip to content

Commit

Permalink
Merge pull request tinybirdco#7 from tinybirdco/fix/image_git_dep
Browse files Browse the repository at this point in the history
Several fixes
  • Loading branch information
jlmadurga authored Jul 25, 2023
2 parents d64cdf5 + b09da8b commit 1b94701
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 10 deletions.
39 changes: 34 additions & 5 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ inpupts.data_project_dir }}
working-directory: ${{ inputs.data_project_dir }}
name: Push changes to Workspace
steps:
- name: Checkout
Expand Down Expand Up @@ -56,8 +56,8 @@ jobs:
- name: Create new test Environment with data
run: |
tb \
--host $TB_HOST \
--token $ADMIN_TOKEN \
--host ${{ secrets.tb_host }} \
--token ${{ secrets.admin_token }} \
env create tmp_cd_${_NORMALIZED_ENV_NAME}_${GITHUB_RUN_ID} \
${_ENV_FLAGS}
Expand All @@ -84,11 +84,13 @@ jobs:
tb release ls
else
CD_DEPLOY_FILE=./deploy/${VERSION}/cd-deploy.sh
if [! -f "$CD_DEPLOY_FILE" ]; then
if [ ! -f "$CD_DEPLOY_FILE" ]; then
tb auth \
--host ${{ secrets.tb_host }} \
--token ${{ secrets.admin_token }}
tb deploy
fi
fi
fi
- name: run post CD deploy commands
run: |
Expand All @@ -100,3 +102,30 @@ jobs:
- name: echo result
run: echo "A new Release with version $VERSION has been deployed in preview status. When you want to make it live use `tb release promote --semver $VERSION`"
cleanup:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ inputs.data_project_dir }}
if: ${{ always() }}
needs: [push_changes]
steps:
- uses: actions/checkout@master
- uses: actions/setup-python@v3
with:
python-version: "3.8"
architecture: "x64"

- name: Install Tinybird CLI
run: pip install tinybird-cli

- name: Tinybird version
run: tb --version

- name: Drop Environment
run: |
tb \
--host ${{ secrets.tb_host }} \
--token ${{ secrets.admin_token }} \
env rm tmp_cd_${_NORMALIZED_ENV_NAME}_${GITHUB_RUN_ID} \
--yes
17 changes: 12 additions & 5 deletions .gitlab/ci_cd.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

stages:
- ci
- cleanup
- cd
- cleanup

variables:
PYTHON_VERSION: "3.11"
Expand All @@ -12,6 +12,8 @@ variables:
stage: ci
image: ${IMAGE_BASE}
interruptible: true
before_script:
- apt-get update && apt-get install -y --no-install-recommends git
script:
- _ENV_FLAGS="${ENV_FLAGS:=--last-partition --wait}"
- cd $CI_PROJECT_DIR/$DATA_PROJECT_DIR
Expand Down Expand Up @@ -72,6 +74,8 @@ variables:
stage: cd
image: ${IMAGE_BASE}
interruptible: true
before_script:
- apt-get update && apt-get install -y --no-install-recommends git
script:
- _ENV_FLAGS="${ENV_FLAGS:=--last-partition --wait}"
- cd $CI_PROJECT_DIR/$DATA_PROJECT_DIR
Expand Down Expand Up @@ -121,7 +125,10 @@ variables:
tb release ls
else
CD_DEPLOY_FILE=./deploy/${VERSION}/cd-deploy.sh
if [! -f "$CD_DEPLOY_FILE" ]; then
if [ ! -f "$CD_DEPLOY_FILE" ]; then
tb auth \
--host $TB_HOST \
--token $ADMIN_TOKEN
tb deploy
fi
fi
Expand All @@ -138,7 +145,7 @@ variables:
image: ${IMAGE_BASE}
script:
- cd $CI_PROJECT_DIR/$DATA_PROJECT_DIR
- _NORMALIZED_ENV_NAME=`echo $DATA_PROJECT_DIR | rev | cut -d "/" -f 1 | rev`
- _NORMALIZED_ENV_NAME=$(echo $DATA_PROJECT_DIR | rev | cut -d "/" -f 1 | rev | tr '.-' '_')

# Create Python Virtual Environment
- python -m venv .venv
Expand All @@ -163,7 +170,7 @@ variables:
image: ${IMAGE_BASE}
script:
- cd $CI_PROJECT_DIR/$DATA_PROJECT_DIR
- _NORMALIZED_ENV_NAME=`echo $DATA_PROJECT_DIR | rev | cut -d "/" -f 1 | rev`
- _NORMALIZED_ENV_NAME=$(echo $DATA_PROJECT_DIR | rev | cut -d "/" -f 1 | rev | tr '.-' '_')

# Create Python Virtual Environment
- python -m venv .venv
Expand All @@ -175,7 +182,7 @@ variables:
# Tinybird version
- tb --version

# Remove test Environment
# Remove Environment
- |
tb \
--host $TB_HOST \
Expand Down

0 comments on commit 1b94701

Please sign in to comment.