Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Add directory filter for IT #1344

Merged
merged 1 commit into from
Nov 24, 2020
Merged

Conversation

pawelpasterz
Copy link
Contributor

@pawelpasterz pawelpasterz commented Nov 24, 2020

Fixes #1337

This PR adds step for IT workflow. It checks with git diff if any modified/removed/created/moved files were in test_runner and/or integration_tests directory.

Test Plan

How do we know the code works?

No straightforward way to do this. The added step is a simple bash script that sets output either to true or false.
To verify you can copy the script and run locally

git diff --name-only --diff-filter=AMDR HEAD^ HEAD > diffs.txt
echo "---------------"
cat diffs.txt
echo "---------------"
SHOULD_RUN='false'
while IFS= read -r file
do
  if [[ $file == test_runner/* ]] || [[ $file == integration_tests/* ]]; then
    SHOULD_RUN='true'
    break
  fi
done < diffs.txt
rm diffs.txt
echo "Should run IT: ${SHOULD_RUN}"
echo "::set-output name=should_run::${SHOULD_RUN}"

If case there are any files changed in test_runner/integration_tests echo "::set-output name=should_run::true" should be printed. Otherwise echo "::set-output name=should_run::false"

@github-actions
Copy link
Contributor

github-actions bot commented Nov 24, 2020

Timestamp: 2020-11-24 11:51:54
Buildscan url for ubuntu-workflow run 380972400
https://gradle.com/s/obdn3tiplc5ym

Copy link
Contributor

@jan-goral jan-goral left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tested it locally using:

#!/bin/bash

git diff --name-only --diff-filter=AMDR HEAD^ HEAD > diffs.txt
echo "---------------"
cat diffs.txt
echo "---------------"
SHOULD_RUN='false'
while IFS= read -r file
do
  if [[ $file == test_runner/* ]] || [[ $file == integration_tests/* ]]; then
    SHOULD_RUN='true'
    break
  fi
done < diffs.txt
rm diffs.txt
echo "::set-output name=should_run::$SHOULD_RUN"

running on a 1313-add-it-test-cases 78eeed3:

MacBook-Pro-jan-gogo:flank-review jan-gogo$ ./testscr.sh 
---------------
integration_tests/src/test/kotlin/integration/AllTestFilteredIT.kt
integration_tests/src/test/kotlin/integration/IgnoreFailedIT.kt
integration_tests/src/test/kotlin/integration/IntergrationTestsUtils.kt
integration_tests/src/test/kotlin/integration/MultipleApksIT.kt
integration_tests/src/test/kotlin/integration/MultipleDevicesIT.kt
integration_tests/src/test/kotlin/integration/RunTimeoutIT.kt
integration_tests/src/test/kotlin/integration/SanityRoboIT.kt
integration_tests/src/test/kotlin/integration/TestFilteringIT.kt
---------------
::set-output name=should_run::true

running on master 8e3bc14:

MacBook-Pro-jan-gogo:flank-review jan-gogo$ ./testscr.sh 
---------------
buildSrc/src/main/kotlin/Versions.kt
---------------
::set-output name=should_run::false

Look like the bash script works fine 👍

@codecov-io
Copy link

codecov-io commented Nov 24, 2020

Codecov Report

Merging #1344 (7c490ed) into master (130e468) will decrease coverage by 0.04%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #1344      +/-   ##
============================================
- Coverage     77.83%   77.79%   -0.05%     
  Complexity      705      705              
============================================
  Files           244      244              
  Lines          4692     4692              
  Branches        901      901              
============================================
- Hits           3652     3650       -2     
  Misses          550      550              
- Partials        490      492       +2     

Copy link
Contributor

@adamfilipow92 adamfilipow92 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First I try to use this script on 1313-add-it-test-cases
Output


---------------
integration_tests/src/test/kotlin/integration/MultipleDevicesIT.kt
---------------
Should run IT: true
::set-output name=should_run::true

and on master:


---------------
.github/workflows/release.yml
flank-actions/sendMessage.kts
---------------
Should run IT: false
::set-output name=should_run::false

I think script works fine! 👍

@piotradamczyk5 piotradamczyk5 merged commit e450298 into master Nov 24, 2020
@piotradamczyk5 piotradamczyk5 deleted the 1337-IT-files-filter branch November 24, 2020 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[IT] Run integration tests only on changes in Flank and/or test projects
5 participants