Skip to content

Commit 9c8fd80

Browse files
authored
airbyte-ci format: make most inputs optional in run-airbyte-ci (#37683)
1 parent 3435613 commit 9c8fd80

File tree

5 files changed

+63
-73
lines changed

5 files changed

+63
-73
lines changed

.github/actions/install-airbyte-ci/action.yml

+2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@ runs:
3636
if [[ "${{ github.ref }}" != "refs/heads/master" ]] && [[ "${{ steps.changes.outputs.pipelines_any_changed }}" == "true" ]]; then
3737
echo "Making changes to Airbyte CI on a non-master branch. Airbyte-CI will be installed from source."
3838
echo "install-mode=source" >> $GITHUB_OUTPUT
39+
echo "SENTRY_ENVIRONMENT=dev" >> $GITHUB_ENV
3940
else
4041
echo "install-mode=binary" >> $GITHUB_OUTPUT
42+
echo "SENTRY_ENVIRONMENT=production" >> $GITHUB_ENV
4143
fi
4244
4345
- name: Install Airbyte CI from binary

.github/actions/run-airbyte-ci/action.yml

+22-24
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ inputs:
99
required: true
1010
github_token:
1111
description: "GitHub token"
12-
required: true
12+
required: false
1313
dagger_cloud_token:
1414
description: "Dagger Cloud token"
15-
required: true
15+
required: false
1616
docker_hub_username:
1717
description: "Dockerhub username"
18-
required: true
18+
required: false
1919
docker_hub_password:
2020
description: "Dockerhub password"
21-
required: true
21+
required: false
2222
options:
2323
description: "Options for the subcommand"
2424
required: false
@@ -93,15 +93,14 @@ runs:
9393
- name: Get start timestamp
9494
id: get-start-timestamp
9595
shell: bash
96-
run: echo "name=start-timestamp=$(date +%s)" >> $GITHUB_OUTPUT
97-
96+
run: echo "start-timestamp=$(date +%s)" >> $GITHUB_OUTPUT
9897
- name: Docker login
9998
id: docker-login
10099
uses: docker/login-action@v3
100+
if: ${{ inputs.docker_hub_username != '' && inputs.docker_hub_password != '' }}
101101
with:
102102
username: ${{ inputs.docker_hub_username }}
103103
password: ${{ inputs.docker_hub_password }}
104-
105104
- name: Install Airbyte CI
106105
id: install-airbyte-ci
107106
uses: ./.github/actions/install-airbyte-ci
@@ -111,19 +110,19 @@ runs:
111110
- name: Run airbyte-ci
112111
id: run-airbyte-ci
113112
shell: bash
114-
run: |
115-
airbyte-ci --disable-update-check --disable-dagger-run --is-ci --gha-workflow-run-id=${{ github.run_id }} ${{ inputs.subcommand }} ${{ inputs.options }}
116113
env:
114+
CI: "True"
115+
CI_GIT_USER: ${{ github.repository_owner }}
116+
CI_PIPELINE_START_TIMESTAMP: ${{ steps.get-start-timestamp.outputs.start-timestamp }}
117+
PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }}
118+
# Next environment variables are workflow inputs based and can be set with empty values if the inputs are not required and passed
117119
CI_CONTEXT: "${{ inputs.context }}"
118-
CI_GIT_REPO_URL: ${{ inputs.git_repo_url }}
119120
CI_GIT_BRANCH: ${{ inputs.git_branch || github.head_ref }}
121+
CI_GIT_REPO_URL: ${{ inputs.git_repo_url }}
120122
CI_GIT_REVISION: ${{ inputs.git_revision || github.sha }}
121-
CI_GIT_USER: ${{ github.repository_owner }}
122123
CI_GITHUB_ACCESS_TOKEN: ${{ inputs.github_token }}
123124
CI_JOB_KEY: ${{ inputs.ci_job_key }}
124-
CI_PIPELINE_START_TIMESTAMP: ${{ steps.get-start-timestamp.outputs.start-timestamp }}
125125
CI_REPORT_BUCKET_NAME: ${{ inputs.report_bucket_name }}
126-
CI: "True"
127126
DAGGER_CLOUD_TOKEN: "${{ inputs.dagger_cloud_token }}"
128127
DOCKER_HUB_PASSWORD: ${{ inputs.docker_hub_password }}
129128
DOCKER_HUB_USERNAME: ${{ inputs.docker_hub_username }}
@@ -133,47 +132,46 @@ runs:
133132
METADATA_SERVICE_BUCKET_NAME: ${{ inputs.metadata_service_bucket_name }}
134133
METADATA_SERVICE_GCS_CREDENTIALS: ${{ inputs.metadata_service_gcs_credentials }}
135134
PRODUCTION: ${{ inputs.production }}
136-
PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }}
137135
PYTHON_REGISTRY_TOKEN: ${{ inputs.python_registry_token }}
138136
PYTHON_REGISTRY_URL: ${{ inputs.python_registry_url }}
139-
PYTHON_REGISTRY_CHECK_URL: ${{ inputs.python_registry_check_url }}
140137
S3_BUILD_CACHE_ACCESS_KEY_ID: ${{ inputs.s3_build_cache_access_key_id }}
141138
S3_BUILD_CACHE_SECRET_KEY: ${{ inputs.s3_build_cache_secret_key }}
142139
SENTRY_DSN: ${{ inputs.sentry_dsn }}
143-
SENTRY_ENVIRONMENT: ${{ steps.determine-install-mode.outputs.install-mode }}
144140
SLACK_WEBHOOK: ${{ inputs.slack_webhook_url }}
145141
SPEC_CACHE_BUCKET_NAME: ${{ inputs.spec_cache_bucket_name }}
146142
SPEC_CACHE_GCS_CREDENTIALS: ${{ inputs.spec_cache_gcs_credentials }}
147-
# give the Dagger Engine more time to push cache data to Dagger Cloud
143+
run: |
144+
airbyte-ci --disable-update-check --disable-dagger-run --is-ci --gha-workflow-run-id=${{ github.run_id }} ${{ inputs.subcommand }} ${{ inputs.options }}
148145
- name: Stop Engine
149146
id: stop-engine
150147
if: always()
151148
shell: bash
152149
run: |
153150
mapfile -t containers < <(docker ps --filter name="dagger-engine-*" -q)
154151
if [[ "${#containers[@]}" -gt 0 ]]; then
152+
# give 5mn to the Dagger Engine to push cache data to Dagger Cloud
155153
docker stop -t 300 "${containers[@]}";
156154
fi
157155
158-
- name: Collect docker logs on failure
159-
id: collect-docker-logs
156+
- name: Collect dagger engine logs
157+
id: collect-dagger-engine-logs
160158
if: always()
161159
uses: jwalton/gh-docker-logs@v2
162160
with:
163-
dest: "./docker_logs"
161+
dest: "./dagger_engine_logs"
164162
images: "registry.dagger.io/engine"
165163

166164
- name: Tar logs
167165
id: tar-logs
168166
if: always()
169167
shell: bash
170-
run: tar cvzf ./docker_logs.tgz ./docker_logs
168+
run: tar cvzf ./dagger_engine_logs.tgz ./dagger_engine_logs
171169

172170
- name: Upload logs to GitHub
173-
id: upload-docker-logs
171+
id: upload-dagger-engine-logs
174172
if: always()
175173
uses: actions/upload-artifact@v4
176174
with:
177-
name: docker_logs.tgz
178-
path: ./docker_logs.tgz
175+
name: dagger_engine_logs.tgz
176+
path: ./dagger_engine_logs.tgz
179177
retention-days: 7

.github/workflows/community_ci.yml

+37
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,43 @@ on:
2121
- "master"
2222

2323
jobs:
24+
format_check:
25+
# IMPORTANT: This name must match the require check name on the branch protection settings
26+
name: "Check for formatting errors"
27+
if: github.event.pull_request.head.repo.fork == true
28+
environment: community-ci-auto
29+
runs-on: community-tooling-test-small
30+
timeout-minutes: 30s
31+
env:
32+
MAIN_BRANCH_NAME: "master"
33+
steps:
34+
# This checkouts a fork which can contain untrusted code
35+
# It's deemed safe as the formatter are not executing any checked out code
36+
- name: Checkout fork
37+
uses: actions/checkout@v4
38+
with:
39+
repository: ${{ github.event.pull_request.head.repo.full_name }}
40+
ref: ${{ github.event.pull_request.head.sha }}
41+
fetch-depth: 1
42+
43+
# This will sync the .github folder of the main repo with the fork
44+
# This allows us to use up to date actions from the main repo
45+
- name: Pull .github folder from main repository
46+
id: pull_github_folder
47+
run: |
48+
git remote add main https://github.com/airbytehq/airbyte.git
49+
git fetch main ${MAIN_BRANCH_NAME}
50+
git checkout main/${MAIN_BRANCH_NAME} -- .github
51+
52+
- name: Run airbyte-ci format check all
53+
# This path refers to the fork .github folder.
54+
# We make sure its content is in sync with the main repo .github folder by pulling it in the previous step
55+
uses: ./.github/actions/run-airbyte-ci
56+
with:
57+
context: "pull_request"
58+
sentry_dsn: ${{ secrets.SENTRY_AIRBYTE_CI_DSN }}
59+
subcommand: "format check all"
60+
is_fork: "true"
2461
connectors_test:
2562
name: Run connectors tests on fork
2663
if: github.event.pull_request.head.repo.fork == true

.github/workflows/connectors_tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ jobs:
6363
# We only run the Connectors CI job if there are changes to the connectors on a non-forked PR
6464
# Forked PRs are handled by the community_ci.yml workflow
6565
# If the condition is not met the job will be skipped (it will not fail)
66-
if: needs.changes.outputs.connectors == 'true' && github.event.pull_request.head.repo.fork != true
66+
if: (github.event_name == 'pull_request' && needs.changes.outputs.connectors == 'true' && github.event.pull_request.head.repo.fork != true) || github.event_name == 'workflow_dispatch'
6767
name: Connectors CI
6868
runs-on: connector-test-large
6969
timeout-minutes: 360 # 6 hours

.github/workflows/format_check.yml

+1-48
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,7 @@ jobs:
3030
continue-on-error: true
3131
with:
3232
context: "master"
33-
dagger_cloud_token: ${{ secrets.DAGGER_CLOUD_TOKEN_2 }}
34-
docker_hub_password: ${{ secrets.DOCKER_HUB_PASSWORD }}
35-
docker_hub_username: ${{ secrets.DOCKER_HUB_USERNAME }}
36-
gcs_credentials: ${{ secrets.METADATA_SERVICE_PROD_GCS_CREDENTIALS }}
3733
sentry_dsn: ${{ secrets.SENTRY_AIRBYTE_CI_DSN }}
38-
github_token: ${{ secrets.GH_PAT_MAINTENANCE_OCTAVIA }}
3934
subcommand: "format check all"
4035

4136
- name: Run airbyte-ci format check [PULL REQUEST]
@@ -45,12 +40,7 @@ jobs:
4540
continue-on-error: false
4641
with:
4742
context: "pull_request"
48-
dagger_cloud_token: ${{ secrets.DAGGER_CLOUD_TOKEN_2 }}
49-
docker_hub_password: ${{ secrets.DOCKER_HUB_PASSWORD }}
50-
docker_hub_username: ${{ secrets.DOCKER_HUB_USERNAME }}
51-
gcs_credentials: ${{ secrets.METADATA_SERVICE_PROD_GCS_CREDENTIALS }}
5243
sentry_dsn: ${{ secrets.SENTRY_AIRBYTE_CI_DSN }}
53-
github_token: ${{ secrets.GH_PAT_MAINTENANCE_OCTAVIA }}
5444
subcommand: "format check all"
5545

5646
- name: Run airbyte-ci format check [WORKFLOW DISPATCH]
@@ -60,12 +50,7 @@ jobs:
6050
continue-on-error: false
6151
with:
6252
context: "manual"
63-
dagger_cloud_token: ${{ secrets.DAGGER_CLOUD_TOKEN_2 }}
64-
docker_hub_password: ${{ secrets.DOCKER_HUB_PASSWORD }}
65-
docker_hub_username: ${{ secrets.DOCKER_HUB_USERNAME }}
66-
gcs_credentials: ${{ secrets.METADATA_SERVICE_PROD_GCS_CREDENTIALS }}
6753
sentry_dsn: ${{ secrets.SENTRY_AIRBYTE_CI_DSN }}
68-
github_token: ${{ secrets.GH_PAT_MAINTENANCE_OCTAVIA }}
6954
subcommand: "format check all"
7055

7156
- name: Match GitHub User to Slack User [MASTER]
@@ -77,7 +62,7 @@ jobs:
7762
GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7863

7964
- name: Format Failure on Master Slack Channel [MASTER]
80-
if: steps.airbyte_ci_format_check_all.outcome == 'failure' && github.ref == 'refs/heads/master'
65+
if: steps.airbyte_ci_format_check_all_master.outcome == 'failure' && github.ref == 'refs/heads/master'
8166
uses: abinoda/slack-action@master
8267
env:
8368
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN_AIRBYTE_TEAM }}
@@ -90,35 +75,3 @@ jobs:
9075
{\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"<@${{ steps.match-github-to-slack-user.outputs.slack_user_ids }}> \n\"}},
9176
{\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\" :octavia-shocked: <https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}|View Action Run> :octavia-shocked: \n\"}},
9277
{\"type\":\"divider\"}]}
93-
94-
# TODO alafanechere: move it to community_ci.yml and make it use the run-airbyte-ci action
95-
format-check-from-forks:
96-
# Same-named job as above, in order to ensure 'required checks' pass either way.
97-
# This should run all the same checks as above, except not requiring any credentials.
98-
name: "Check for formatting errors"
99-
if: >
100-
github.event.pull_request.head.repo.fork == true
101-
runs-on: ubuntu-latest
102-
steps:
103-
# We have no creds. Ignore docker caching and just run the CLI.
104-
- name: Checkout code (Unprivileged)
105-
uses: actions/checkout@v4
106-
with:
107-
ref: ${{ github.event.pull_request.head.ref }}
108-
repository: ${{ github.event.pull_request.head.repo.full_name }}
109-
fetch-depth: 1
110-
- name: Set up Python
111-
uses: actions/setup-python@v5
112-
with:
113-
python-version: "3.10"
114-
115-
- name: Install Airbyte CI from binary
116-
id: install-airbyte-ci-binary
117-
shell: bash
118-
run: |
119-
curl -sSL "https://connectors.airbyte.com/airbyte-ci/releases/ubuntu/latest/airbyte-ci" --output airbyte-ci-bin
120-
sudo mv airbyte-ci-bin /usr/local/bin/airbyte-ci
121-
sudo chmod +x /usr/local/bin/airbyte-ci
122-
- name: Run format checks
123-
run: |
124-
/usr/local/bin/airbyte-ci --disable-update-check format check all

0 commit comments

Comments
 (0)