Skip to content

Commit

Permalink
Only generate CI jobs for languages that need to be tested (#6278)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajohnstonTE authored Jan 8, 2021
1 parent 929900d commit 39c47f7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
17 changes: 15 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@ jobs:
echo "COMMIT_MESSAGE<<EOF" >> $GITHUB_ENV
echo "$(git log --format=%B -n 1 HEAD^2)" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- uses: actions/setup-python@v2
with:
python-version: '2.7'
architecture: 'x64'
- name: Get all changes vs master
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
DIFF=$(./toolset/github_actions/github_actions_diff.py)
echo "RUN_TESTS<<EOF" >> $GITHUB_ENV
echo "$(grep -oP "github-actions-run-tests \K(.*)" <<< $DIFF || true)" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- id: event_out
name: Write event outputs
run: |
Expand All @@ -53,15 +65,16 @@ jobs:
# include:
# - TESTLANG: {lang}
# with a TESTLANG object in the include array for each language under frameworks
VERIFY_MATRIX=$(ls -1 frameworks | jq -R | jq -sc "{include: map({TESTLANG: .})}")
VERIFY_MATRIX=$(ls -1 frameworks | jq -Rc '.+"/" | select(inside(env.RUN_TESTS)) | rtrimstr("/")' | jq -sc '{include: map({TESTLANG: .})}')
echo "::set-output name=verify_matrix::$VERIFY_MATRIX"
outputs:
commit_message: ${{ steps.event_out.outputs.commit_message }}
branch_name: ${{ steps.event_out.outputs.branch_name }}
verify_matrix: ${{ steps.verify_out.outputs.verify_matrix }}
verify:
needs: setup
if: ${{ !contains(needs.setup.outputs.commit_message, '[ci skip]') }}
# The matrix check is necessary because an empty job matrix is otherwise considered a workflow failure
if: ${{ !contains(needs.setup.outputs.commit_message, '[ci skip]') && contains(needs.setup.outputs.verify_matrix, 'TESTLANG') }}
runs-on: ubuntu-18.04
strategy:
matrix: ${{ fromJSON(needs.setup.outputs.verify_matrix) }}
Expand Down
10 changes: 10 additions & 0 deletions toolset/github_actions/github_actions_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,16 @@ def quit_diffing():
filter(lambda x: os.path.isdir(dir + x), os.listdir(dir)))
elif os.getenv("TESTDIR"):
test_dirs = os.getenv("TESTDIR").split(' ')
else:
def get_frameworks(test_lang):
dir = "frameworks/" + test_lang + "/"
return map(lambda x: test_lang + "/" + x,
filter(lambda x: os.path.isdir(dir + x),
os.listdir(dir)))
test_dirs = []
for frameworks in map(get_frameworks, os.listdir("frameworks")):
for framework in frameworks:
test_dirs.append(framework)

# Forced full run
if (not is_PR and is_master) or re.search(r'\[ci run-all\]', last_commit_msg, re.M):
Expand Down

0 comments on commit 39c47f7

Please sign in to comment.