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: Implement workflow for full suite IT (cron + manual) #1353

Merged
merged 14 commits into from
Dec 14, 2020

Conversation

pawelpasterz
Copy link
Contributor

@pawelpasterz pawelpasterz commented Nov 25, 2020

Fixes #1351

What it actually does?

Basically, the workflow runs integration tests (IT) and reacts to results. If there are tests failed an issue is created with the IT_Failed label.

Screenshot 2020-12-01 at 14 57 20

and a comment is added with build scan URL + list of commits from the last run (and associated PRs)

Screenshot 2020-12-01 at 14 59 39

If an issue with the IT_Failed label is already created only comment is added to the existing ticket. Once the IT run is succeeded issue is closed automatically.

Screenshot 2020-12-01 at 15 02 11

Workflow is implemented to listen to 2 triggers:

  • scheduled (at 00:00 every workday)
  • manual

Workflow is divided into 3 main sections

  1. build and run IT
  2. prepare message (specific for 1) results)
  3. create issue or close issue or add comment *or skip

More detailed workflow step-by-step

  1. Run IT
    1. checkout the code, build and run integrationTests task
  2. Process results
    1. check if the issue is already opened
    2. get time when the workflow was started last time, skip cancelled and in_progress (sets output last-run-date)
    3. create either a success or failure message
    4. for failure message:
      1. get a list of commits since the last run
      2. for each commit get associated PR
      3. append the results table
    5. make comment body
    6. decide what to do next:
      1. if IT status is success and no issue opened -- do nothing
      2. if IT status is success and there is an issue opened -- add a comment and close the issue
      3. it IT status is failure and there is no issue opened -- create an issue and add comment
      4. if IT status is failure and there is issue opened -- add comment

Test Plan

How do we know the code works?

Note:
flank-scrips has Flank/flank repo hardcoded (and some other variables). I will implement a feature to make life easier while testing scripts in the near future...
For now, before the build, please replace:

(PAT with full access needed)

  1. build flank locally ./gradlew build
  2. run java -jar ./flank-scripts/build/libs/flank-scripts.jar integration processResults --result success --url https://any.url --github-token $(echo $GITHUB_TOKEN) --run-id 123456
  3. no issue created
    ** Parameters:
          result: SUCCESS
          url:    https://any.url
          runID:  123456
    ** No workflow run found for full_suite_integration_tests.yml
    ** No opened issue
    
  4. run java -jar ./flank-scripts/build/libs/flank-scripts.jar integration processResults --result failure --url https://any.url --github-token $(echo $GITHUB_TOKEN) --run-id 123456
  5. new issue was created
  6. run java -jar ./flank-scripts/build/libs/flank-scripts.jar integration processResults --result success --url https://any.url --github-token $(echo $GITHUB_TOKEN) --run-id 123456
  7. a comment was added
  8. run java -jar ./flank-scripts/build/libs/flank-scripts.jar integration processResults --result success --url https://any.url --github-token $(echo $GITHUB_TOKEN) --run-id 123456
  9. issue was closed

Example

Example issue pawelpasterz#25
Contains all steps (create, add a comment, and close)

Checklist

  • Add manual trigger
  • Add cron trigger
  • Run IT and publish build scan
  • Set status for IT job
  • Find last run date (filter cancelled and in progress)
  • Find commits since last run (and associated PRs)
  • Check for already opened issue
  • Create success message
  • Create failure message
  • Choose next step
  • Add comment job
  • Create issue job
  • Close issue job
  • flank-scripts
  • run only on master

@github-actions
Copy link
Contributor

github-actions bot commented Nov 25, 2020

Timestamp: 2020-12-14 05:18:44
Buildscan url for ubuntu-workflow run 419964851
https://gradle.com/s/dzqnhrweigzwq

@pawelpasterz pawelpasterz marked this pull request as draft November 26, 2020 13:14
@pawelpasterz
Copy link
Contributor Author

pawelpasterz commented Nov 26, 2020

Some changes to be implemented:

  • job should gather a list of commits since last IT run
  • find PR for listed commits
  • build scan URL + PRs list should be separated comment
  • if the issue already created, add a comment instead of creating a new one

cc
@piotradamczyk5 @jan-gogo

@jan-goral
Copy link
Contributor

Some changes to be implemented:

* job should gather a list of commits since last IT run

* find PR for listed commits

* build scan URL + PRs list should be separated comment

* if the issue already created, add a comment instead of creating a new one

cc
@piotradamczyk5 @jan-gogo

#1351 (comment)

@pawelpasterz pawelpasterz changed the title ci: Implement cron job for full suite IT ci: Implement workflow for full suite IT (cron + manual) Dec 1, 2020
@codecov-io
Copy link

codecov-io commented Dec 1, 2020

Codecov Report

Merging #1353 (a256556) into master (8f49608) will decrease coverage by 0.02%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #1353      +/-   ##
============================================
- Coverage     77.61%   77.58%   -0.03%     
  Complexity      717      717              
============================================
  Files           248      248              
  Lines          4788     4788              
  Branches        915      915              
============================================
- Hits           3716     3715       -1     
  Misses          572      572              
- Partials        500      501       +1     

@pawelpasterz pawelpasterz force-pushed the 1351-add-it-cron-job branch 2 times, most recently from bf90c3b to c49b850 Compare December 1, 2020 14:30
@pawelpasterz pawelpasterz marked this pull request as ready for review December 1, 2020 14:31
@pawelpasterz pawelpasterz force-pushed the 1351-add-it-cron-job branch 2 times, most recently from 8257dcc to 8a4808a Compare December 2, 2020 08:02
Copy link
Contributor

@Sloox Sloox left a comment

Choose a reason for hiding this comment

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

If this is blocked shall we move it to draft?

@piotradamczyk5
Copy link
Contributor

Once the IT run is succeeded issue is closed automatically.

I do not agree with this condition, because later on we will have running it on custom branches and the issue could be closed without resolution

Copy link
Contributor

@piotradamczyk5 piotradamczyk5 left a comment

Choose a reason for hiding this comment

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

Please resolve comments and update flank-scripts/readme.md also

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.

Great work! Only a few minor formatting style-related suggestions.
I have to perform manual tests.

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.

Tested step by step, everything works fine

MacBook-Pro-jan-gogo:flank-jan-gogo jan-gogo$ java -jar ./flank-scripts/build/libs/flank-scripts.jar integration processResults --result success --url https://any.url --github-token $(echo $GITHUB_TOKEN) --run-id 123456
** Parameters:
     result: SUCCESS
     url:    https://any.url
     runID:  123456
** No workflow run found for full_suite_integration_tests.yml
** No opened issue
MacBook-Pro-jan-gogo:flank-jan-gogo jan-gogo$ java -jar ./flank-scripts/build/libs/flank-scripts.jar integration processResults --result failure --url https://any.url --github-token $(echo $GITHUB_TOKEN) --run-id 123456
** Parameters:
     result: FAILURE
     url:    https://any.url
     runID:  123456
** No workflow run found for full_suite_integration_tests.yml
** No opened issue
** Creating new issue
{
    "title": "Full Suite integration tests failed on master",
    "body": "### Integration Test failed on master",
    "labels": [
        "IT_Failed",
        "bug"
    ]
}
Error while doing GitHub request, because of Issues are disabled for this repo, more info at https://docs.github.com/v3/issues/
MacBook-Pro-jan-gogo:flank-jan-gogo jan-gogo$ java -jar ./flank-scripts/build/libs/flank-scripts.jar integration processResults --result failure --url https://any.url --github-token $(echo $GITHUB_TOKEN) --run-id 123456
** Parameters:
     result: FAILURE
     url:    https://any.url
     runID:  123456
** No workflow run found for full_suite_integration_tests.yml
** No opened issue
** Creating new issue
{
    "title": "Full Suite integration tests failed on master",
    "body": "### Integration Test failed on master",
    "labels": [
        "IT_Failed",
        "bug"
    ]
}
** Issue created:
     url:    https://github.com/jan-gogo/flank/issues/3
     number: 3 
** Comment posted
{
    "body": "### Full suite IT run :x: FAILED :x:\n**Timestamp:** 2020-12-11 14:04:23\n**Job run:** [123456](https://github.com/Flank/flank/actions/runs/123456\n**Build scan URL:** https://any.url\nNo new commits\n"
}
MacBook-Pro-jan-gogo:flank-jan-gogo jan-gogo$ java -jar ./flank-scripts/build/libs/flank-scripts.jar integration processResults --result success --url https://any.url --github-token $(echo $GITHUB_TOKEN) --run-id 123456
** Parameters:
     result: SUCCESS
     url:    https://any.url
     runID:  123456
** No workflow run found for full_suite_integration_tests.yml
** Issue found: https://github.com/jan-gogo/flank/issues/3
** Comment posted
{
    "body": "### Full suite IT run :white_check_mark: SUCCEEDED :white_check_mark:\n**Timestamp:** 2020-12-11 14:04:48\n**Job run:** [123456](https://github.com/Flank/flank/actions/runs/123456\n**Build scan URL:** https://any.url\n**Closing issue**"
}
** Closing issue
MacBook-Pro-jan-gogo:flank-jan-gogo jan-gogo$ java -jar ./flank-scripts/build/libs/flank-scripts.jar integration processResults --result success --url https://any.url --github-token $(echo $GITHUB_TOKEN) --run-id 123456
** Parameters:
     result: SUCCESS
     url:    https://any.url
     runID:  123456
** No workflow run found for full_suite_integration_tests.yml
** No opened issue
MacBook-Pro-jan-gogo:flank-jan-gogo jan-gogo$ 

@piotradamczyk5
Copy link
Contributor

@Mergifyio rebase

@mergify
Copy link

mergify bot commented Dec 11, 2020

Command rebase: action_required

Pull request must be rebased manually.
GitHub App like Mergify are not allowed to rebase pull request where .github/workflows is changed.

@pawelpasterz pawelpasterz merged commit 44800ce into master Dec 14, 2020
@pawelpasterz pawelpasterz deleted the 1351-add-it-cron-job branch December 14, 2020 06:03
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] Add workflow for full suite IT
6 participants