From 082492e775cb1f5dc9d20bb2e47375395db0697d Mon Sep 17 00:00:00 2001 From: Jake Hemstad Date: Tue, 30 May 2023 07:37:32 -0500 Subject: [PATCH] Disable current workflow and test split workflow. --- .github/workflows/per_cuda.yml | 16 +++++++++ .github/workflows/pr.yml | 10 +++--- .github/workflows/test_new_workflow.yml | 46 +++++++++++++++++++++++++ ci/get_groups.sh | 16 +++++++++ ci/group_by_field.jq | 4 +++ 5 files changed, 87 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/per_cuda.yml create mode 100644 .github/workflows/test_new_workflow.yml create mode 100755 ci/get_groups.sh create mode 100644 ci/group_by_field.jq diff --git a/.github/workflows/per_cuda.yml b/.github/workflows/per_cuda.yml new file mode 100644 index 0000000000..0e99ec2bec --- /dev/null +++ b/.github/workflows/per_cuda.yml @@ -0,0 +1,16 @@ +name: Per CUDA version + +on: + workflow_call: + inputs: + per_cuda_matrix: {type: string, required: true} + +test-repo-per-cuda-ver: + uses: ./.github/workflows/test-repo-per-compiler.yml + strategy: + matrix: ${{ fromJSON(inputs.cuda_vers) }} + with: + repo: ${{ inputs.repo }} + cxx_vers: ${{ inputs.cxx_vers }} + cuda_ver: ${{ matrix.cuda_ver }} + compilers: ${{ inputs.compilers }} \ No newline at end of file diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 0d04abba3e..9013a9fc8c 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -5,11 +5,11 @@ defaults: run: shell: bash -on: - push: - branches: - - main - - "pull-request/[0-9]+" +#on: +# push: +# branches: +# - main +# - "pull-request/[0-9]+" # Only runs one instance of this workflow at a time for a given PR and cancels any in-progress runs when a new one starts. concurrency: diff --git a/.github/workflows/test_new_workflow.yml b/.github/workflows/test_new_workflow.yml new file mode 100644 index 0000000000..f394185a71 --- /dev/null +++ b/.github/workflows/test_new_workflow.yml @@ -0,0 +1,46 @@ + +# This is the main workflow that runs on every PR and push to main +name: pr_split + +defaults: + run: + shell: bash + +on: + push: + branches: + - main + - "pull-request/[0-9]+" + +# Only runs one instance of this workflow at a time for a given PR and cancels any in-progress runs when a new one starts. +concurrency: + group: ${{ github.workflow }}-on-${{ github.event_name }}-from-${{ github.ref_name }} + cancel-in-progress: true + +jobs: + compute-matrix: + runs-on: ubuntu-latest + outputs: + BUILD_MATRIX: ${{ steps.compute-matrix.outputs.BUILD_MATRIX }} + PER_CUDA_MATRIX: ${{ steps.compute-matrix.outputs.PER_CUDA_MATRIX }} + CUDA_VERSIONS: ${{ steps.compute-matrix.outputs.CUDA_VERSIONS }} + steps: + - name: Checkout repo + uses: actions/checkout@v3 + - name: Compute matrix + id: compute-matrix + run: | + cat ./ci/matrix.yaml + BUILD_MATRIX=$(yq -o=json ./ci/matrix.yaml | jq -c '[.include[] | . as $o | {std: .std[]} + del($o.std)] | {include: . }' ) + echo "BUILD_MATRIX=$BUILD_MATRIX" | tee -a "$GITHUB_OUTPUT" + PER_CUDA_MATRIX=./ci/get_groups.sh $BUILD_MATRIX cuda $GITHUB_OUTPUT + CUDA_VERSIONS=$(echo $PER_CUDA_MATRIX | jq 'keys') + echo "CUDA_VERSIONS=$CUDA_VERSIONS" | tee -a "$GITHUB_OUTPUT" + + thrust: + needs: compute-matrix + uses: ./.github/workflows/per_cuda.yml + strategy: + matrix: ${{ fromJSON(needs.compute-matrix.outputs.CUDA_VERSIONS) }} }} + with: + per_cuda_matrix: ${{ needs.compute-matrix.outputs.PER_CUDA_MATRIX }} \ No newline at end of file diff --git a/ci/get_groups.sh b/ci/get_groups.sh new file mode 100755 index 0000000000..e41152d5e0 --- /dev/null +++ b/ci/get_groups.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +# Check if input JSON, field, and file arguments are provided +if [ "$#" -ne 3 ]; then + echo "Usage: ./get_groups.sh " + exit 1 +fi + +# Assign command-line arguments to variables +input_json="$1" +field="$2" +output_file="$3" + +output=$(echo $input_json | jq -c --arg field "$field" 'include "group_by_field"; .include | group_by_field($field)') +echo $output | tee -a "$output_file" + diff --git a/ci/group_by_field.jq b/ci/group_by_field.jq new file mode 100644 index 0000000000..d074a0a655 --- /dev/null +++ b/ci/group_by_field.jq @@ -0,0 +1,4 @@ +# Groups an array of objects by a field and returns an object with the field value as key and the array of objects as value +# Handles nested fields (e.g. "compiler.name") +def group_by_field($field): + group_by(getpath($field | split("."))) | map( {(.[0] | getpath($field | split("."))): .}) | add;