From 69c5800f9e50c774e75dbe227e5b66fe01c21959 Mon Sep 17 00:00:00 2001
From: DriesSchaumont <5946712+DriesSchaumont@users.noreply.github.com>
Date: Tue, 30 Jan 2024 09:40:15 +0100
Subject: [PATCH 01/10] Add component test CI
---
.github/workflows/test.yaml | 99 +++++++++++++++++++++++++++++++++++++
1 file changed, 99 insertions(+)
create mode 100644 .github/workflows/test.yaml
diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml
new file mode 100644
index 00000000..9b12bd89
--- /dev/null
+++ b/.github/workflows/test.yaml
@@ -0,0 +1,99 @@
+name: Component Testing
+
+on:
+ pull_request:
+ push:
+ branches: [ '**' ]
+
+jobs:
+ run_ci_check_job:
+ runs-on: ubuntu-latest
+ outputs:
+ run_ci: ${{ steps.github_cli.outputs.check }}
+ steps:
+ - name: 'Check if branch has an existing pull request and the trigger was a push'
+ id: github_cli
+ run: |
+ pull_request=$(gh pr list -R ${{ github.repository }} -H ${{ github.ref_name }} --json url --state open --limit 1 | jq '.[0].url')
+ # If the branch has a PR and this run was triggered by a push event, do not run
+ if [[ "$pull_request" != "null" && "$GITHUB_REF_NAME" != "main" && "${{ github.event_name == 'push' }}" == "true" && "${{ !contains(github.event.head_commit.message, 'ci force') }}" == "true" ]]; then
+ echo "check=false" >> $GITHUB_OUTPUT
+ else
+ echo "check=true" >> $GITHUB_OUTPUT
+ fi
+
+ # phase 1
+ list:
+ needs: run_ci_check_job
+ runs-on: ubuntu-latest
+ if: ${{ needs.run_ci_check_job.outputs.run_ci == 'true' }}
+
+ outputs:
+ matrix: ${{ steps.set_matrix.outputs.matrix }}
+
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+
+ - uses: viash-io/viash-actions/setup@v5
+
+ - name: Check if all config can be parsed if there is no unicode support
+ run: |
+ LANG=C viash ns list > /dev/null
+
+ - name: Get changed files
+ id: changed-files
+ uses: tj-actions/changed-files@v42
+ with:
+ separator: ";"
+ diff_relative: true
+
+ - id: ns_list
+ uses: viash-io/viash-actions/ns-list@v5
+ with:
+ platform: docker
+ format: json
+ query_namespace: ^(?!workflows)
+
+ - id: ns_list_filtered
+ uses: viash-io/viash-actions/project/detect-changed-components@v5
+ with:
+ input_file: "${{ steps.ns_list.outputs.output_file }}"
+
+ - id: set_matrix
+ run: |
+ echo "matrix=$(jq -c '[ .[] |
+ {
+ "name": (.functionality.namespace + "/" + .functionality.name),
+ "config": .info.config,
+ "dir": .info.config | capture("^(?
.*\/)").dir
+ }
+ ]' ${{ steps.ns_list_filtered.outputs.output_file }} )" >> $GITHUB_OUTPUT
+
+ # phase 2
+ viash_test:
+ needs: list
+ if: ${{ needs.list.outputs.matrix != '[]' && needs.list.outputs.matrix != '' }}
+ runs-on: ubuntu-latest
+
+ strategy:
+ fail-fast: false
+ matrix:
+ component: ${{ fromJson(needs.list.outputs.matrix) }}
+
+ steps:
+ # Remove unnecessary files to free up space. Otherwise, we get 'no space left on device.'
+ - uses: data-intuitive/reclaim-the-bytes@v2
+
+ - uses: actions/checkout@v4
+
+ - uses: viash-io/viash-actions/setup@v5
+
+ - name: Run test
+ timeout-minutes: 30
+ run: |
+ viash test \
+ "${{ matrix.component.config }}" \
+ --cpus 2 \
+ --memory "6gb"
\ No newline at end of file
From 8b7a4e84c0e40edbc10236fb3866851446fa86ce Mon Sep 17 00:00:00 2001
From: DriesSchaumont <5946712+DriesSchaumont@users.noreply.github.com>
Date: Tue, 30 Jan 2024 09:43:57 +0100
Subject: [PATCH 02/10] activate CI [ci force]
From 8c6e0dae83d59c525833d3532da32e75dabadf77 Mon Sep 17 00:00:00 2001
From: DriesSchaumont <5946712+DriesSchaumont@users.noreply.github.com>
Date: Tue, 30 Jan 2024 09:45:37 +0100
Subject: [PATCH 03/10] activate CI [ci force]
From 32d52d71154c59a4442625dacbfe1fbfface6d57 Mon Sep 17 00:00:00 2001
From: DriesSchaumont <5946712+DriesSchaumont@users.noreply.github.com>
Date: Tue, 30 Jan 2024 09:57:21 +0100
Subject: [PATCH 04/10] Use ns_list output when adding [ci force]
---
.github/workflows/test.yaml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml
index 9b12bd89..6479bfca 100644
--- a/.github/workflows/test.yaml
+++ b/.github/workflows/test.yaml
@@ -69,7 +69,7 @@ jobs:
"config": .info.config,
"dir": .info.config | capture("^(?.*\/)").dir
}
- ]' ${{ steps.ns_list_filtered.outputs.output_file }} )" >> $GITHUB_OUTPUT
+ ]' ${{ !contains(github.event.head_commit.message, 'ci force') && steps.ns_list.outputs.output_file || steps.ns_list_filtered.outputs.output_file }} )" >> $GITHUB_OUTPUT
# phase 2
viash_test:
From 6c1c3a98d95a068140255c079aa5a7ab829e10f1 Mon Sep 17 00:00:00 2001
From: DriesSchaumont <5946712+DriesSchaumont@users.noreply.github.com>
Date: Tue, 30 Jan 2024 10:00:35 +0100
Subject: [PATCH 05/10] Fix check
---
.github/workflows/test.yaml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml
index 6479bfca..cf7fcfa3 100644
--- a/.github/workflows/test.yaml
+++ b/.github/workflows/test.yaml
@@ -69,7 +69,7 @@ jobs:
"config": .info.config,
"dir": .info.config | capture("^(?.*\/)").dir
}
- ]' ${{ !contains(github.event.head_commit.message, 'ci force') && steps.ns_list.outputs.output_file || steps.ns_list_filtered.outputs.output_file }} )" >> $GITHUB_OUTPUT
+ ]' ${{ contains(github.event.head_commit.message, 'ci force') && steps.ns_list.outputs.output_file || steps.ns_list_filtered.outputs.output_file }} )" >> $GITHUB_OUTPUT
# phase 2
viash_test:
From 394a5d99505ba79aa9e8b6419d8971d6a32ee2a9 Mon Sep 17 00:00:00 2001
From: DriesSchaumont <5946712+DriesSchaumont@users.noreply.github.com>
Date: Tue, 30 Jan 2024 10:12:09 +0100
Subject: [PATCH 06/10] Make it work for PRs [ci force]
---
.github/workflows/test.yaml | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml
index cf7fcfa3..0c98c3d8 100644
--- a/.github/workflows/test.yaml
+++ b/.github/workflows/test.yaml
@@ -34,7 +34,11 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
- fetch-depth: 0
+ fetch-depth: 0
+
+ - name: Get head git commit message
+ id: get_head_commit_message
+ run: echo "HEAD_COMMIT_MESSAGE=$(git show -s --format=%s)" >> "$GITHUB_OUTPUT"
- uses: viash-io/viash-actions/setup@v5
@@ -69,7 +73,7 @@ jobs:
"config": .info.config,
"dir": .info.config | capture("^(?.*\/)").dir
}
- ]' ${{ contains(github.event.head_commit.message, 'ci force') && steps.ns_list.outputs.output_file || steps.ns_list_filtered.outputs.output_file }} )" >> $GITHUB_OUTPUT
+ ]' ${{ contains(steps.get_head_commit_message.outputs.HEAD_COMMIT_MESSAGE, 'ci force') && steps.ns_list.outputs.output_file || steps.ns_list_filtered.outputs.output_file }} )" >> $GITHUB_OUTPUT
# phase 2
viash_test:
From f3802272df06496ae9fd9440624a711f84cc2f78 Mon Sep 17 00:00:00 2001
From: DriesSchaumont <5946712+DriesSchaumont@users.noreply.github.com>
Date: Tue, 30 Jan 2024 10:17:43 +0100
Subject: [PATCH 07/10] Use GH_TOKEN
---
.github/workflows/test.yaml | 2 ++
1 file changed, 2 insertions(+)
diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml
index 0c98c3d8..fbcea762 100644
--- a/.github/workflows/test.yaml
+++ b/.github/workflows/test.yaml
@@ -21,6 +21,8 @@ jobs:
else
echo "check=true" >> $GITHUB_OUTPUT
fi
+ env:
+ GH_TOKEN: ${{ github.token }}
# phase 1
list:
From d33f51c2cf3f449fc7459529c772c8fd2ed23a30 Mon Sep 17 00:00:00 2001
From: DriesSchaumont <5946712+DriesSchaumont@users.noreply.github.com>
Date: Tue, 30 Jan 2024 10:33:57 +0100
Subject: [PATCH 08/10] Get message from GITHUB_SHA
---
.github/workflows/test.yaml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml
index fbcea762..30f0a813 100644
--- a/.github/workflows/test.yaml
+++ b/.github/workflows/test.yaml
@@ -40,7 +40,7 @@ jobs:
- name: Get head git commit message
id: get_head_commit_message
- run: echo "HEAD_COMMIT_MESSAGE=$(git show -s --format=%s)" >> "$GITHUB_OUTPUT"
+ run: echo "HEAD_COMMIT_MESSAGE=$(git show -s --format=%s $GITHUB_SHA)" >> "$GITHUB_OUTPUT"
- uses: viash-io/viash-actions/setup@v5
From 1e75f376d9f2f0239f922f0bf3076327ca2f23f3 Mon Sep 17 00:00:00 2001
From: DriesSchaumont <5946712+DriesSchaumont@users.noreply.github.com>
Date: Tue, 30 Jan 2024 10:39:02 +0100
Subject: [PATCH 09/10] Use head branch [ci force]
---
.github/workflows/test.yaml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml
index 30f0a813..585bda6b 100644
--- a/.github/workflows/test.yaml
+++ b/.github/workflows/test.yaml
@@ -40,7 +40,7 @@ jobs:
- name: Get head git commit message
id: get_head_commit_message
- run: echo "HEAD_COMMIT_MESSAGE=$(git show -s --format=%s $GITHUB_SHA)" >> "$GITHUB_OUTPUT"
+ run: echo "HEAD_COMMIT_MESSAGE=$(git show -s --format=%s ${{ github.event.pull_request.head.sha || github.sha }})" >> "$GITHUB_OUTPUT"
- uses: viash-io/viash-actions/setup@v5
From 08a2500230998c678d783017df92c619cf5099a3 Mon Sep 17 00:00:00 2001
From: DriesSchaumont <5946712+DriesSchaumont@users.noreply.github.com>
Date: Tue, 30 Jan 2024 10:47:11 +0100
Subject: [PATCH 10/10] Fix query [ci force]
---
.github/workflows/test.yaml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml
index 585bda6b..a094248b 100644
--- a/.github/workflows/test.yaml
+++ b/.github/workflows/test.yaml
@@ -60,7 +60,7 @@ jobs:
with:
platform: docker
format: json
- query_namespace: ^(?!workflows)
+ query: ^(?!workflows)
- id: ns_list_filtered
uses: viash-io/viash-actions/project/detect-changed-components@v5