-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
airbyte-ci: CLI exposes CI requirements
- Loading branch information
1 parent
e93703d
commit 91b9c91
Showing
10 changed files
with
207 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
name: "Get airbyte-ci runner name" | ||
description: "Runs a given airbyte-ci command with the --ci-requirements flag to get the CI requirements for a given command" | ||
inputs: | ||
runner_type: | ||
description: "Type of runner to get requirements for. One of: format, test, nightly, publish" | ||
required: true | ||
runner_size: | ||
description: "One of: format, test, nightly, publish" | ||
required: true | ||
airbyte_ci_command: | ||
description: "airbyte-ci command to get CI requirements for." | ||
required: true | ||
runner_name_prefix: | ||
description: "Prefix of runner name" | ||
required: false | ||
default: ci-runner-connector | ||
github_token: | ||
description: "GitHub token" | ||
required: true | ||
sentry_dsn: | ||
description: "Sentry DSN" | ||
required: false | ||
airbyte_ci_binary_url: | ||
description: "URL to airbyte-ci binary" | ||
required: false | ||
default: https://connectors.airbyte.com/airbyte-ci/releases/ubuntu/latest/airbyte-ci | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Check if PR is from a fork | ||
if: github.event_name == 'pull_request' | ||
shell: bash | ||
run: | | ||
if [ "${{ github.event.pull_request.head.repo.fork }}" == "true" ]; then | ||
echo "PR is from a fork. Exiting workflow..." | ||
exit 78 | ||
fi | ||
- name: Get changed files | ||
uses: tj-actions/changed-files@v39 | ||
id: changes | ||
with: | ||
files_yaml: | | ||
pipelines: | ||
- 'airbyte-ci/connectors/pipelines/**' | ||
- name: Determine how Airbyte CI should be installed | ||
shell: bash | ||
id: determine-install-mode | ||
run: | | ||
if [[ "${{ github.ref }}" != "refs/heads/master" ]] && [[ "${{ steps.changes.outputs.pipelines_any_changed }}" == "true" ]]; then | ||
echo "Making changes to Airbyte CI on a non-master branch. Airbyte-CI will be installed from source." | ||
echo "install-mode=dev" >> $GITHUB_OUTPUT | ||
else | ||
echo "install-mode=production" >> $GITHUB_OUTPUT | ||
fi | ||
- name: Install airbyte-ci binary | ||
id: install-airbyte-ci | ||
if: steps.determine-install-mode.outputs.install-mode == 'production' | ||
shell: bash | ||
run: | | ||
curl -sSL ${{ inputs.airbyte_ci_binary_url }} --output airbyte-ci-bin | ||
sudo mv airbyte-ci-bin /usr/local/bin/airbyte-ci | ||
sudo chmod +x /usr/local/bin/airbyte-ci | ||
- name: Install Python 3.10 | ||
uses: actions/setup-python@v4 | ||
if: steps.determine-install-mode.outputs.install-mode == 'dev' | ||
with: | ||
python-version: "3.10" | ||
token: ${{ inputs.github_token }} | ||
|
||
- name: Install ci-connector-ops package | ||
if: steps.determine-install-mode.outputs.install-mode == 'dev' | ||
shell: bash | ||
run: | | ||
pip install pipx | ||
pipx ensurepath | ||
pipx install airbyte-ci/connectors/pipelines/ | ||
- name: Get dagger version from airbyte-ci | ||
id: get-dagger-version | ||
shell: bash | ||
run: | | ||
dagger_version=$(airbyte-ci --disable-dagger-run --is-ci --gha-workflow-run-id=${{ github.run_id }} ${{ inputs.subcommand }} --ci-requirements | tail -n 1 | jq -r '.dagger_version') | ||
echo "dagger_version=${dagger_version}" >> "$GITHUB_OUTPUT" | ||
- name: Get runner name | ||
id: get-runner-name | ||
shell: bash | ||
run: | | ||
runner_name_prefix=${{ inputs.runner_name_prefix }} | ||
runner_type=${{ inputs.runner_type }} | ||
runner_size=${{ inputs.runner_size }} | ||
dashed_dagger_version=$(echo "${{ steps.get-dagger-version.outputs.dagger_version }}" | tr '.' '-') | ||
runner_name="${runner_name_prefix}-${runner_type}-dagger-${runner_size}-${dashed_dagger_version}" | ||
echo ${runner_name} | ||
echo "runner_name=${runner_name}" >> "$GITHUB_OUTPUT" | ||
outputs: | ||
runner_name: ${{ steps.get-runner-name.outputs.runner_name }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
airbyte-ci/connectors/pipelines/pipelines/models/ci_requirements.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Copyright (c) 2023 Airbyte, Inc., all rights reserved. | ||
|
||
import json | ||
from dataclasses import dataclass | ||
from importlib import metadata | ||
|
||
INFRA_SUPPORTED_DAGGER_VERSIONS = { | ||
"0.6.4", | ||
"0.9.5", | ||
} | ||
|
||
|
||
@dataclass | ||
class CIRequirements: | ||
""" | ||
A dataclass to store the CI requirements. | ||
It used to make airbyte-ci client define the CI runners it will run on. | ||
""" | ||
|
||
dagger_version = metadata.version("dagger-io") | ||
|
||
def __post_init__(self): | ||
if self.dagger_version not in INFRA_SUPPORTED_DAGGER_VERSIONS: | ||
raise ValueError( | ||
f"Unsupported dagger version: {self.dagger_version}. " f"Supported versions are: {INFRA_SUPPORTED_DAGGER_VERSIONS}." | ||
) | ||
|
||
def to_json(self): | ||
return json.dumps( | ||
{ | ||
"dagger_version": self.dagger_version, | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters