Skip to content

Commit

Permalink
Merge branch 'main' into clickup-integrations
Browse files Browse the repository at this point in the history
  • Loading branch information
oiadebayo authored Sep 16, 2024
2 parents b0a5db2 + 119cf98 commit 9f171dd
Show file tree
Hide file tree
Showing 217 changed files with 17,804 additions and 15,528 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ jobs:
file: ${{ steps.prepare_tags.outputs.dockerfile_path }}
platforms: linux/amd64,linux/arm64
push: false
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ${{ steps.prepare_tags.outputs.tags }}
build-args: |
BUILD_CONTEXT=${{ steps.prepare_tags.outputs.context_dir }}
Expand Down
42 changes: 42 additions & 0 deletions .github/workflows/detect-changes-matrix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Detect Changes
on:
workflow_call:
outputs:
matrix:
value: ${{ jobs.detect-changes.outputs.matrix }}
description: "Matrix of changed integrations per git commit changes"

jobs:
detect-changes:
name: Detect changes
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout Repo
uses: actions/checkout@v4

- name: Get list of changed files
id: changed-files
uses: tj-actions/[email protected]
- name: Set matrix
id: set-matrix
run: |
folders_to_ignore="integrations/*/LICENSE.md|integrations/*/README.md|integrations/*/CONTRIBUTING.md|integrations/*/CHANGELOG.md"
changed_folders=$(echo "${{ steps.changed-files.outputs.all_changed_files }}" \
| tr ' ' '\n' | grep '^integrations/' | grep -v '^($folders_to_ignore)' \
| egrep -v '_infra' \
| cut -d'/' -f2 | sort | uniq)
if [ -z "$changed_folders" ]; then
changed_folders=""
fi
folders_to_ignore="integrations/|scripts/|assets/|docs/|LICENSE.md|README.md|CONTRIBUTING.md|CHANGELOG.md"
other_changes=$(echo "${{ steps.changed-files.outputs.all_changed_files }}" | tr ' ' '\n' | grep -v '^($folders_to_ignore)' | wc -l)
if [ "$other_changes" -ne 0 ]; then
# Add the root directory to the matrix if there are changes outside the integrations folder
changed_folders=$(echo -e "$changed_folders\n.")
fi
matrix=$(echo "$changed_folders" | jq -R -s -c 'split("\n") | map(select(length > 0))')
echo "matrix=$matrix" >> $GITHUB_OUTPUT
38 changes: 6 additions & 32 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,7 @@ on:

jobs:
detect-changes:
name: Detect changes
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout Repo
uses: actions/checkout@v4

- name: Get list of changed files
id: changed-files
uses: tj-actions/[email protected]
- name: Set matrix
id: set-matrix
run: |
folders_to_ignore="integrations/*/LICENSE.md|integrations/*/README.md|integrations/*/CONTRIBUTING.md|integrations/*/CHANGELOG.md"
changed_folders=$(echo "${{ steps.changed-files.outputs.all_changed_files }}" | tr ' ' '\n' | grep '^integrations/' | grep -v '^($folders_to_ignore)' | cut -d'/' -f2 | sort | uniq)
if [ -z "$changed_folders" ]; then
changed_folders=""
fi
folders_to_ignore="integrations/|scripts/|assets/|docs/|LICENSE.md|README.md|CONTRIBUTING.md|CHANGELOG.md"
other_changes=$(echo "${{ steps.changed-files.outputs.all_changed_files }}" | tr ' ' '\n' | grep -v '^($folders_to_ignore)' | wc -l)
if [ "$other_changes" -ne 0 ]; then
# Add the root directory to the matrix if there are changes outside the integrations folder
changed_folders=$(echo -e "$changed_folders\n.")
fi
matrix=$(echo "$changed_folders" | jq -R -s -c 'split("\n") | map(select(length > 0))')
echo "matrix=$matrix" >> $GITHUB_OUTPUT
uses: ./.github/workflows/detect-changes-matrix.yml
lint:
name: ${{ matrix.folder == '.' && '🌊 Ocean Core' || format('🚢 {0}', matrix.folder) }}
needs: detect-changes
Expand All @@ -44,12 +15,15 @@ jobs:
matrix:
folder: ${{ fromJson(needs.detect-changes.outputs.matrix) }}
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Install poetry
run: pipx install poetry
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Checkout Repo
uses: actions/checkout@v4
cache: 'poetry'
- name: Install dependencies
working-directory: ${{ matrix.folder != '.' && format('integrations/{0}', matrix.folder) || '.' }}
run: |
Expand Down
109 changes: 59 additions & 50 deletions .github/workflows/release-integrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ jobs:
contents: read
needs: [prepare-matrix]
strategy:
# limit the number of parallel jobs to avoid hitting the ghcr.io rate limit
max-parallel: 15
matrix:
integration: ${{fromJson(needs.prepare-matrix.outputs.matrix)}}
steps:
Expand Down Expand Up @@ -113,6 +115,8 @@ jobs:
file: ${{ steps.prepare_tags.outputs.dockerfile_path }}
platforms: linux/amd64,linux/arm64
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ${{ steps.prepare_tags.outputs.tags }}
build-args: |
BUILD_CONTEXT=${{ steps.prepare_tags.outputs.context_dir }}
Expand Down Expand Up @@ -146,59 +150,64 @@ jobs:
aws_s3_bucket="ocean-registry"
# Fetch existing index file or create empty one of not exists
if aws s3 ls "s3://$aws_s3_bucket/$index_file" > /dev/null 2>&1; then
aws s3 cp "s3://$aws_s3_bucket/$index_file" $index_file
echo "Successfully fetched global index file from s3 bucket."
if aws s3 ls "s3://$aws_s3_bucket/$index_file" >/dev/null 2>&1; then
aws s3 cp "s3://$aws_s3_bucket/$index_file" $index_file
echo "Successfully fetched global index file from s3 bucket."
else
echo "Index file does not exist in the S3 bucket, Creating new one..."
echo "[]" > "$index_file"
echo "Index file does not exist in the S3 bucket, Creating new one..."
echo "[]" >"$index_file"
fi
# Find all ocean-spec.yaml files under the specified directory
find integrations/*/.port -type f -name "spec.yaml" > file_list.txt
find integrations/*/.port -type f -name "spec.yaml" >file_list.txt
while IFS= read -r file; do
integration_dir=$(dirname "$file")
integration_name=$(echo "$integration_dir" | awk -F'/' '{print $2}')
# Extract the type for pyproject.toml
type=$(grep -E '^name = ".*"' "$integration_dir/../pyproject.toml" | cut -d'"' -f2)
# Extract the version from pyproject.toml
version=$(grep -E '^version = ".*"' "$integration_dir/../pyproject.toml" | cut -d'"' -f2)
integration_spec="$integration_name-$version.json"
integration_dest="$integration_name/$integration_spec"
integration_legacy_dest="$integration_name.json" # TODO: legacy support, remove once not in use
# Convert YAML to JSON
yq -o json "$file" > "$temp_file"
# Add version attribute
jq --arg type "$type" --arg version "$version" '. + {type: $type, version: $version}' "$temp_file" > "$integration_spec"
# Upload integration's version manifest to s3
aws s3 cp "$integration_spec" "s3://$aws_s3_bucket/$integration_dest"
aws s3 cp "$integration_spec" "s3://$aws_s3_bucket/$integration_legacy_dest" # TODO: legacy support, remove once not in use
echo "Successfully uploaded $integration_spec to s3 bucket."
# Get the latest version of the current integration
latest_version=$(jq --arg type "$type" -r '.[] | select(.type == $type) | .version' "$index_file")
# Add integration's spec to global index file
regexp="^[0-9.]+$"
if [[ ! "$latest_version" ]]; then
# Add new integration spec if latest tag doesn't exist
jq --argjson new_spec "[$(cat "$integration_spec")]" '. += $new_spec' "$index_file" > "$temp_file"
mv "$temp_file" "$index_file"
elif [[ ! "$latest_version" =~ $regexp ]] || [[ "$version" =~ $regexp ]]; then
# Override global index file if released non-dev version or integration doesn't have non-dev latest tag
jq --argjson updated_spec "$(cat "$integration_spec")" --arg type "$type" \
'map(if .type == $type then $updated_spec else . end)' "$index_file" > "$temp_file"
mv "$temp_file" "$index_file"
fi
done < file_list.txt
# Upload global index file to s3
aws s3 cp "$index_file" "s3://$aws_s3_bucket/$index_file"
echo "Successfully uploaded $index_file to s3 bucket."
integration_dir=$(dirname "$file")
integration_name=$(echo "$integration_dir" | awk -F'/' '{print $2}')
# Extract the type for pyproject.toml
type=$(grep -E '^name = ".*"' "$integration_dir/../pyproject.toml" | cut -d'"' -f2)
# Extract the version from pyproject.toml
version=$(grep -E '^version = ".*"' "$integration_dir/../pyproject.toml" | cut -d'"' -f2)
integration_spec="$integration_name-$version.json"
integration_dest="$integration_name/$integration_spec"
integration_legacy_dest="$integration_name.json" # TODO: legacy support, remove once not in use
# Convert YAML to JSON
yq -o json "$file" >"$temp_file"
# Add version attribute
jq --arg type "$type" --arg version "$version" '. + {type: $type, version: $version}' "$temp_file" >"$integration_spec"
if [[ ! ${version} =~ ^.+-dev$ ]]; then
# Upload integration's version manifest to s3
aws s3 cp "$integration_spec" "s3://$aws_s3_bucket/$integration_dest"
aws s3 cp "$integration_spec" "s3://$aws_s3_bucket/$integration_legacy_dest" # TODO: legacy support, remove once not in use
echo "Successfully uploaded $integration_spec to s3 bucket."
# Get the latest version of the current integration
latest_version=$(jq --arg type "$type" -r '.[] | select(.type == $type) | .version' "$index_file")
# Add integration's spec to global index file
regexp="^[0-9.]+$"
if [[ ! "$latest_version" ]]; then
# Add new integration spec if latest tag doesn't exist
jq --argjson new_spec "[$(cat "$integration_spec")]" '. += $new_spec' "$index_file" >"$temp_file"
mv "$temp_file" "$index_file"
elif [[ ! "$latest_version" =~ $regexp ]] || [[ "$version" =~ $regexp ]]; then
# Override global index file if released non-dev version or integration doesn't have non-dev latest tag
jq --argjson updated_spec "$(cat "$integration_spec")" --arg type "$type" \
'map(if .type == $type then $updated_spec else . end)' "$index_file" >"$temp_file"
mv "$temp_file" "$index_file"
fi
# Upload global index file to s3
aws s3 cp "$index_file" "s3://$aws_s3_bucket/$index_file"
echo "Successfully uploaded $index_file to s3 bucket."
else
echo "Did not upload integration spec since the version was in development ('${version}')"
fi
done <file_list.txt
50 changes: 18 additions & 32 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,7 @@ on:

jobs:
detect-changes:
name: Detect changes
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout Repo
uses: actions/checkout@v4

- name: Get list of changed files
id: changed-files
uses: tj-actions/[email protected]
- name: Set matrix
id: set-matrix
run: |
folders_to_ignore="integrations/*/LICENSE.md|integrations/*/README.md|integrations/*/CONTRIBUTING.md|integrations/*/CHANGELOG.md"
changed_folders=$(echo "${{ steps.changed-files.outputs.all_changed_files }}" | tr ' ' '\n' | grep '^integrations/' | grep -v '^($folders_to_ignore)' | cut -d'/' -f2 | sort | uniq)
if [ -z "$changed_folders" ]; then
changed_folders=""
fi
folders_to_ignore="integrations/|scripts/|assets/|docs/|LICENSE.md|README.md|CONTRIBUTING.md|CHANGELOG.md"
other_changes=$(echo "${{ steps.changed-files.outputs.all_changed_files }}" | tr ' ' '\n' | grep -v '^($folders_to_ignore)' | wc -l)
if [ "$other_changes" -ne 0 ]; then
# Add the root directory to the matrix if there are changes outside the integrations folder
changed_folders=$(echo -e "$changed_folders\n.")
fi
matrix=$(echo "$changed_folders" | jq -R -s -c 'split("\n") | map(select(length > 0))')
echo "matrix=$matrix" >> $GITHUB_OUTPUT
uses: ./.github/workflows/detect-changes-matrix.yml
test:
name: ${{ matrix.folder == '.' && '🌊 Ocean Core' || format('🚢 {0}', matrix.folder) }}
needs: detect-changes
Expand All @@ -44,12 +15,15 @@ jobs:
matrix:
folder: ${{ fromJson(needs.detect-changes.outputs.matrix) }}
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Install poetry
run: pipx install poetry
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Checkout Repo
uses: actions/checkout@v4
cache: 'poetry'
- name: Install dependencies
working-directory: ${{ matrix.folder != '.' && format('integrations/{0}', matrix.folder) || '.' }}
run: |
Expand All @@ -60,6 +34,18 @@ jobs:
PYTEST_ADDOPTS: --junitxml=junit/test-results-${{ matrix.folder != '.' && format('integrations/{0}', matrix.folder) || 'ocean/core' }}.xml
run: |
make test
- name: Install current core for all integrations
working-directory: ${{ matrix.folder != '.' && format('integrations/{0}', matrix.folder) || '.' }}
if: ${{ matrix.folder == '.' }}
run: |
echo "Installing local core for all integrations"
SCRIPT_TO_RUN='make install/local-core' make execute/all
- name: Test all integrations with current core
working-directory: ${{ matrix.folder != '.' && format('integrations/{0}', matrix.folder) || '.' }}
if: ${{ matrix.folder == '.' }}
run: |
echo "Testing all integrations with local core"
SCRIPT_TO_RUN="PYTEST_ADDOPTS=--junitxml=${PWD}/junit/test-results-core-change/\`pwd | xargs basename\`.xml make test" make execute/all
- name: Publish Test Report
uses: mikepenz/action-junit-report@v4
if: ${{ always() }}
Expand Down
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ repos:
- id: detect-aws-credentials
- repo: local
hooks:
- id: lint
name: Run linter
description: This hooks runs our linters
entry: make lint
- id: fix lint
name: Fix linter
description: This hooks fixes our linters
entry: make lint/fix
language: system
types:
- python
11 changes: 11 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,17 @@
"python": "${workspaceFolder}/integrations/aws/.venv/bin/python",
"request": "launch",
"type": "debugpy"
},
{
"console": "integratedTerminal",
"cwd": "${workspaceFolder}/integrations/test-integration",
"envFile": "${workspaceFolder}/integrations/test-integration/.env",
"justMyCode": true,
"name": "Run test-integration integration",
"program": "${workspaceFolder}/integrations/test-integration/debug.py",
"python": "${workspaceFolder}/integrations/test-integration/.venv/bin/python",
"request": "launch",
"type": "debugpy"
}
]
}
40 changes: 40 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,46 @@ this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

<!-- towncrier release notes start -->

## 0.10.10 (2024-09-12)

### Bug Fixes

- Fixed failing on initialization of the integration when one of the actions exists in port

### Improvements

- Added fix lint command to the makefile as well as the pre-commit hook


## 0.10.9 (2024-09-05)

### Bug Fixes

- Replaced StopAsyncIteration with a return statement to ignore prevent errors in cases where empty tasks are sent to the stream_async_iterators_tasks function


## 0.10.8 (2024-09-04)

### Bug Fixes

- Avoid raising exception when receiving ReadTimeout on batch upsert entities
- Increased both internal port client and third party client timeout to handle long requests


## 0.10.7 (2024-08-28)

### Improvements

- Add search identifier support (Allow to run a search query to find the identifier of the entity as part of the mapping)


## 0.10.6 (2024-08-31)

### Bug Fixes

- Fixed error log when looking for existence of integration on initialization


## 0.10.5 (2024-08-27)

### Improvements
Expand Down
Loading

0 comments on commit 9f171dd

Please sign in to comment.