-
Notifications
You must be signed in to change notification settings - Fork 56
60 lines (54 loc) · 2.23 KB
/
lint.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
name: Lint
on:
pull_request:
workflow_dispatch:
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
lint:
name: ${{ matrix.folder == '.' && '🌊 Ocean Core' || format('🚢 {0}', matrix.folder) }}
needs: detect-changes
runs-on: ubuntu-latest
strategy:
matrix:
folder: ${{ fromJson(needs.detect-changes.outputs.matrix) }}
steps:
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Checkout Repo
uses: actions/checkout@v4
- name: Install dependencies
working-directory: ${{ matrix.folder != '.' && format('integrations/{0}', matrix.folder) || '.' }}
run: |
make install
- name: Lint
working-directory: ${{ matrix.folder != '.' && format('integrations/{0}', matrix.folder) || '.' }}
run: |
make lint