-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
not clean environment after ci and more #19
Changes from all commits
18d3ff8
b1ed43d
c4604f7
36b7c66
7c52b20
6955602
948a9ed
d3c2ff5
563b295
a658134
5d2a95f
fd51a54
543f6a8
376ac30
423cd09
510051f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ jobs: | |
defaults: | ||
run: | ||
working-directory: ${{ inputs.data_project_dir }} | ||
if: ${{ github.event.action != 'closed' }} | ||
steps: | ||
- uses: actions/checkout@master | ||
with: | ||
|
@@ -43,8 +44,15 @@ jobs: | |
source .tinyenv | ||
echo "GIT_BRANCH=$GIT_BRANCH" >> $GITHUB_ENV | ||
echo "_ENV_FLAGS=$_ENV_FLAGS" >> $GITHUB_ENV | ||
echo "_NORMALIZED_ENV_NAME=$_NORMALIZED_ENV_NAME" >> $GITHUB_ENV | ||
|
||
- name: Install Tinybird CLI | ||
run: pip install tinybird-cli | ||
run: | | ||
if [ -f "requirements.txt" ]; then | ||
pip install -r requirements.txt | ||
else | ||
pip install tinybird-cli | ||
fi | ||
|
||
- name: Tinybird version | ||
run: tb --version | ||
|
@@ -55,12 +63,28 @@ jobs: | |
- name: Check auth | ||
run: tb --host ${{ secrets.tb_host }} --token ${{ secrets.tb_admin_token }} auth info | ||
|
||
- name: Try delete previous Environment | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's see how workflows evolve but it would be nice to create a proper github action to use our cli so we can encapsulate this kind of things as they getting complex (also getting advantage of our cli docker image). |
||
run: | | ||
output=$(tb --host ${{ secrets.tb_host }} --token ${{ secrets.tb_admin_token }} env ls) | ||
ENVIRONMENT_NAME="tmp_ci_${_NORMALIZED_ENV_NAME}_${{ github.event.pull_request.number }}" | ||
|
||
# Check if the environment name exists in the output | ||
if echo "$output" | grep -q "\b$ENVIRONMENT_NAME\b"; then | ||
tb \ | ||
--host ${{ secrets.tb_host }} \ | ||
--token ${{ secrets.tb_admin_token }} \ | ||
env rm $ENVIRONMENT_NAME \ | ||
--yes | ||
else | ||
echo "Skipping clean up: The Environment '$ENVIRONMENT_NAME' does not exist." | ||
fi | ||
|
||
- name: Create new test Environment with data | ||
run: | | ||
tb \ | ||
--host ${{ secrets.tb_host }} \ | ||
--token ${{ secrets.tb_admin_token }} \ | ||
env create tmp_ci_${_NORMALIZED_ENV_NAME}_${GITHUB_RUN_ID} \ | ||
env create tmp_ci_${_NORMALIZED_ENV_NAME}_${{ github.event.pull_request.number }} \ | ||
${_ENV_FLAGS} | ||
|
||
- name: List changes with Main Environment | ||
|
@@ -98,6 +122,7 @@ jobs: | |
|
||
- name: Run pipe regression tests | ||
run: | | ||
source .tinyenv | ||
echo ${{ steps.regression_labels.outputs.labels }} | ||
REGRESSION_LABELS=$(echo "${{ steps.regression_labels.outputs.labels }}" | awk -F, '{for (i=1; i<=NF; i++) if ($i ~ /^--/) print $i}' ORS=',' | sed 's/,$//') | ||
echo ${REGRESSION_LABELS} | ||
|
@@ -107,8 +132,7 @@ jobs: | |
defaults: | ||
run: | ||
working-directory: ${{ inputs.data_project_dir }} | ||
if: ${{ always() }} | ||
needs: [ci_branching] | ||
if: ${{ github.event.action == 'closed' }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this requires users to add the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK. Let's remember to add in our generated yml from cli |
||
steps: | ||
- uses: actions/checkout@master | ||
- uses: actions/setup-python@v3 | ||
|
@@ -121,15 +145,28 @@ jobs: | |
[[ "${{ secrets.tb_admin_token }}" ]] || { echo "Go to the tokens section in your Workspace, copy the 'admin token (user@domain.com)' associated to a user account and set TB_ADMIN_TOKEN as a Secret in your Git repository"; exit 1; } | ||
|
||
- name: Install Tinybird CLI | ||
run: pip install tinybird-cli | ||
run: | | ||
if [ -f "requirements.txt" ]; then | ||
pip install -r requirements.txt | ||
else | ||
pip install tinybird-cli | ||
fi | ||
|
||
- name: Tinybird version | ||
run: tb --version | ||
|
||
- name: Drop test Environment | ||
- name: Try delete previous Environment | ||
run: | | ||
tb \ | ||
--host ${{ secrets.tb_host }} \ | ||
--token ${{ secrets.tb_admin_token }} \ | ||
env rm tmp_ci_${_NORMALIZED_ENV_NAME}_${GITHUB_RUN_ID} \ | ||
--yes | ||
output=$(tb --host ${{ secrets.tb_host }} --token ${{ secrets.tb_admin_token }} env ls) | ||
ENVIRONMENT_NAME="tmp_ci_${_NORMALIZED_ENV_NAME}_${{ github.event.pull_request.number }}" | ||
|
||
# Check if the environment name exists in the output | ||
if echo "$output" | grep -q "\b$ENVIRONMENT_NAME\b"; then | ||
tb \ | ||
--host ${{ secrets.tb_host }} \ | ||
--token ${{ secrets.tb_admin_token }} \ | ||
env rm $ENVIRONMENT_NAME \ | ||
--yes | ||
else | ||
echo "Skipping clean up: The Environment '$ENVIRONMENT_NAME' does not exist." | ||
fi |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Next release | ||
============ | ||
|
||
- Support for a `requirements.txt` file inside the Data Project folder. That way you can control which version of the `tinybird-cli` to install. | ||
- Environments in CI are now created with a fixed name using the Pull Request number. | ||
- Environments are not cleaned up after CI finishes. This is a very convenient workflow to debug issues directly in the Environment with the changes of the branch deployed. | ||
- Users updating from previous versions need to do some actions: | ||
- GitHub: Add the `closed` type like [this](https://github.com/tinybirdco/ci_analytics/pull/12/commits/01a207ab2dac38a18ea76c81b0b3087ad3f9cb91). | ||
- GitLab: Change the rule to run the clean up job on merge: | ||
|
||
```yaml | ||
- &cli_cleanup_rule | ||
if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH | ||
changes: | ||
- .gitlab-ci.yml | ||
- ./**/* | ||
when: always | ||
``` | ||
- If you have doubts when updating just drop the .github or .gitlab-ci.yml workflow and re-run `tb init --git` using the latest version of `tinybird-cli` to re-generate the CI/CD templates. | ||
- `.tinyenv` now supports `export OBFUSCATE_REGEX_PATTERN=<regex>` to have a list of regex separated by `|` to obfuscate the output of regression tests. It requires version 1.0.1 of tinybird-cli. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is to run these jobs manually
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK I added the if in this PR not to be triggered but I guess they were executed automatically