Skip to content

Commit

Permalink
fix code freeze workflow (airbytehq#33672)
Browse files Browse the repository at this point in the history
  • Loading branch information
alafanechere authored and jatinyadav-cc committed Feb 26, 2024
1 parent 0dd86e9 commit 6c9eeea
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 9 deletions.
69 changes: 61 additions & 8 deletions .github/workflows/connector_code_freeze.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
name: Connector Code freeze
# This workflow is meant to be used to prevent/discourage merging to master during code freeze.
# The code freeze dates are set in the env variables CODE_FREEZE_START_DATE and CODE_FREEZE_END_DATE.
# If any connector code has been changed we display a warning message reminding merging is blocked and who to contact.
# If no connector connector code has been changed we only display a warning message reminding merging is discouraged.
# The Code freeze check job will be set as a required check for PRs in branch protection rules.

name: Code freeze

on:
pull_request:
Expand All @@ -7,20 +13,67 @@ on:
- synchronize
- ready_for_review

env:
CODE_FREEZE_START_DATE: "2023-12-21"
CODE_FREEZE_END_DATE: "2024-01-02"
jobs:
code-freeze-check:
name: Connector code freeze check
runs-on: ubuntu-latest
name: Code freeze check
permissions:
# This is required to be able to comment on PRs and list changed files
pull-requests: write

steps:
- name: Checkout Airbyte
uses: actions/checkout@v3
# Check if code freeze is in effect by comparing the current date with the start and end date of the code freeze
- name: Check code freeze in effect
id: check-code-freeze-in-effect
run: |
start_date=$(date -d "$CODE_FREEZE_START_DATE" +%s)
end_date=$(date -d "$CODE_FREEZE_END_DATE" +%s)
current_date=$(date +%s)
if [ "$current_date" -ge "$start_date" ] && [ "$current_date" -le "$end_date" ]; then
echo "Code freeze is in effect"
echo "::set-output name=is_in_code_freeze::true"
else
echo "Code freeze is not in effect"
echo "::set-output name=is_in_code_freeze::false"
fi
# Use GitHub PR Api to get the list of changed files
# Filter the list to only keep the connectors files
- name: Get changed files
uses: tj-actions/changed-files@v39
if: steps.check-code-freeze-in-effect.outputs.is_in_code_freeze == 'true'
id: changed-files
uses: tj-actions/changed-files@v40
with:
files_yaml: |
connectors:
- 'airbyte-integration/connectors/**'
- 'airbyte-integrations/connectors/**'
- '!**/*.md'
- name: Fail workflow if connector files was changed
if: steps.changes.outputs.connectors_any_changed == 'true'
# If any connector code has been changed we display a warning message reminding merging is blocked and who to contact
- name: Code freeze comment on PR
if: steps.changed-files.outputs.connectors_any_changed == 'true' && steps.check-code-freeze-in-effect.outputs.is_in_code_freeze == 'true'
uses: thollander/actions-comment-pull-request@v2
with:
comment_tag: code_freeze_warning
message: |
> [!WARNING]
> <b>🚨 Connector code freeze is in effect until ${{ env.CODE_FREEZE_END_DATE }}. This PR is changing connector code. Please contact the current OC engineers if you want to merge this change to master.</b>
# If no connector code has been changed we only display a warning message reminding merging is discouraged
- name: Code freeze comment on PR
if: steps.changed-files.outputs.connectors_any_changed == 'false' && steps.check-code-freeze-in-effect.outputs.is_in_code_freeze == 'true'
uses: thollander/actions-comment-pull-request@v2
with:
comment_tag: code_freeze_warning
message: |
> [!WARNING]
> <b>Soft code freeze is in effect until ${{ env.CODE_FREEZE_END_DATE }}. Please avoid merging to master. #freedom-and-responsibility</b>
# Fail the workflow if connector code has been changed to prevent merging to master
- name: Fail workflow if connector code has been changed
if: steps.changed-files.outputs.connectors_any_changed == 'true' && steps.check-code-freeze-in-effect.outputs.is_in_code_freeze == 'true'
run: echo "Connector code freeze is in effect. Please contact the current OC engineers if you want to merge this change." && exit 1
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ data:
icon: pokeapi.svg
license: MIT
name: PokeAPI
releaseDate: "2020-05-04"
releaseDate: "2020-05-14"
releaseStage: alpha
supportLevel: community
documentationUrl: https://docs.airbyte.com/integrations/sources/pokeapi
Expand Down

0 comments on commit 6c9eeea

Please sign in to comment.