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

e2e #324

Merged
merged 27 commits into from Dec 20, 2022
Merged

e2e #324

merged 27 commits into from Dec 20, 2022

Conversation

shubhbapna
Copy link
Contributor

@shubhbapna shubhbapna commented Dec 12, 2022

Resolves #107 (finally!)

Originally these were supposed to be integration tests but after giving it more thought, the things we wanted to test correspond to actual user stories and so I think it is better to call them end-to-end tests (e2e).

All e2e tests are under test/e2e and you can execute then by running npm run test:e2e. I would also recommend this with logging enabled so that you can see the pure act output as well. You can do so by running ACT_LOG=true npm run test:e2e

Limitations: Well there are still certain limitations which resulted in me making some minor changes to the source code to make testing easier. Essentially, the ACT env variable triggers certain dev features for methods, such as getCloneUrl. Moreover, we cannot auto detect starting project because the GITHUB_REPOSITORY variable is not set properly when run in act. This is because act is not able to parse that info for local repositories (i.e. where you use a file path and not an url). See here - act's way of getting git repository name

Tests implemented:

  • single
    • target:branchA/target:branchB
    • target:branchA/source:branchB
    • target:branchA/source_differentName:branchB

Note: The clone case tests were included in the ones above because these tests are pretty time consuming and it did not make sense to run a complete workflow just to see if additional clones were being made especially when you can easily include that in the tests above

  • cross-pr and full-downstream
    • starting job's dependencies being mapped (mapping.dependencies.X)
    • any dependency being mapped (mapping.dependant.X)

Notes:

  • Exclusion case is included in the above (same reasoning like the clone case)

  • For the first 3 test cases for cross-pr that are mentioned in the issue, the first 2 are also included in the above 2 test cases. The third one however, imo, we don't need it. The source_differentName only makes an impact on the starting project, which is essentially covered by the single test cases.

  • branch:

    • full downstream
    • cross pr

Notes:

  • I wasn't exactly sure what was meant by single and multiple project but since branch is allowed to have 2 modes -fdb and cross-pr I just tested those without going into as much detail since most cases are already covered

@shubhbapna shubhbapna marked this pull request as ready for review December 15, 2022 02:09
Copy link
Contributor

@Ginxo Ginxo left a comment

Choose a reason for hiding this comment

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

Copy link
Contributor

@Ginxo Ginxo left a comment

Choose a reason for hiding this comment

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

please check my comments, many thanks!

src/bin/runners/github-action-runner.ts Show resolved Hide resolved
src/service/config/configuration-service.ts Show resolved Hide resolved
src/service/git/octokit.ts Show resolved Hide resolved
@shubhbapna
Copy link
Contributor Author

GH PR checks should run e2e tests, right?

They are pretty time consuming (The current runtime being 70s or so). Maybe we could have it as part of publish instead or have nightlies?

@Ginxo
Copy link
Contributor

Ginxo commented Dec 19, 2022

GH PR checks should run e2e tests, right?

They are pretty time consuming (The current runtime being 70s or so). Maybe we could have it as part of publish instead or have nightlies?

the time shouldn't be a problem from PR checks perspective specially for the amount of time you mean, so post a PR and just wait for the PR checks to be over (while you do different things). wdyt?

Copy link
Contributor

@Ginxo Ginxo left a comment

Choose a reason for hiding this comment

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

LGTM

@Ginxo Ginxo merged commit b504297 into kiegroup:typescript/main Dec 20, 2022
Ginxo added a commit that referenced this pull request Jan 2, 2023
* Nodejs 16

* rmdirSync error fixed

* prettier

* pull_request.yml improved

* Typescript/main (#262)

* project scaffolding

* .gitignore

* report.yml flow adapted to typescript/main

* logger services implemented

* eslint

* jest

* Add DI library (#265)

* project scaffolding

* .gitignore

* report.yml flow adapted to typescript/main

* logger services implemented

* eslint

* jest

* Add DI library

* logger service tests (#266)

* project scaffolding

* .gitignore

* report.yml flow adapted to typescript/main

* logger services implemented

* eslint

* jest

* Add DI library

* implement loggerservice tests

* test:report script (#267)

* package-lock.json updated

* logger service refactored (#268)

* added jest as dev dependency which is needed by ts-jest (#269)

* solve "-Dsonar.projectName" from report file

* sonar report fixes

* pull_request.yml added npm install and npm run test:report. nodejs 12.x version removed

* added husky (#273)

* Arguments (#270)

* added cli argument parser for build and tool actions

* added cli parser test cases

* Add DI library (#265)

* project scaffolding

* .gitignore

* report.yml flow adapted to typescript/main

* logger services implemented

* eslint

* jest

* Add DI library

* logger service tests (#266)

* project scaffolding

* .gitignore

* report.yml flow adapted to typescript/main

* logger services implemented

* eslint

* jest

* Add DI library

* implement loggerservice tests

* test:report script (#267)

* package-lock.json updated

* logger service refactored (#268)

* added jest as dev dependency which is needed by ts-jest (#269)

* updated package.json

* added action.yml

* added documentation

* Create pull_request.yml

* 12.x removed from pull_request.yml

* implemented requested changes

* increased test coverage

* Update action.yml

Co-authored-by: Enrique Mingorance Cano <ginxaco@gmail.com>

* changed command option naming for token, cct and command. Fixed linting errors

Co-authored-by: Enrique Mingorance Cano <emingora@redhat.com>
Co-authored-by: Enrique Mingorance Cano <ginxaco@gmail.com>
Co-authored-by: Github <noreply@github.com>

* Git service (#274)

* implemented and tested git actions which don't use ocktokit

* added octokit git functions, test cases and created git mock env

* git config changes for test setup

* fix ci arror

* added test cases for octokit factory

* refactored and implemented github-api service

* Executor Service (#272)

* project scaffolding

* .gitignore

* report.yml flow adapted to typescript/main

* logger services implemented

* eslint

* jest

* Add DI library

* implement loggerservice tests

* implement command-executor

* logger service refactored

* export-command-executor.test.ts and export-command-executor.ts

* treatment

* command-builder.test.ts and implementation adapted

* command-treatment-delegator.test.ts

* maven-command-treatment.test.ts

* regex-command-treatment.test.ts

* improving coverage

* execute-command-service.ts basic stuff

* configuration-service implemented and covered

* test-logger-service.ts empty implementation

* test-logger-service.ts empty implementation

* command-executor-delegator.test.ts

* execute-command-service.test.ts

* execute-command-service.test.ts expectedCalls contract improved

* injection from constructors

* hrtime to util/date

* added types for build-chain-configuration-reader (#275)

* Typescript/system requirements (#276)

* About Commands to Execute (#257)

* system requirements section

* Inputs (#278)

* refactored arguments. restructed argument folder to contain cli folder. created a common input parser class

* refactored BuildActionType enum to FlowType and set logger level when debug flag is passed

* updated test to check for logger level

* renamed arguments/main-command-factory to arguments/cli

* added action input parser

* added documentation

* changed ParsedInputs to InputService, refactored test cases

* update logger level for debug option in the cli parser instead of input service

* added skip project execution and checkout (#279)

* Config service (#281)

* added configuration service

* added test cases for action configuration and fixed bugs for action configuration

* added cli congfiguration tests. Bug fixes in cli configuration. Refactored action configuration test

* added util tests

* added more test for cli and action config. Removed unnecessary code from base config

* added some test cases for configuration service

* refactored types for definition file

* load definition file in configuration

* refactored build-config-reader types and definition file loader in config service

* added more test cases for config service and added getTreatmentOption method

* fixed treatment options and custom command treatment option

* added parser to convert project nodes from build-config-reader to node domain object

* removed old config service

* added input validation

* bug fix in test setup

* added documentation

* updated with requested changes

* Code smells (#283)

* remove redundant await

* extracted nested ternary operations into independent statements

* remove nested string literals

* prefix unused function parameters with underscore

* remove mocks for coverage

* fix empty expect in logger test

* linted domain files

* linted arguments service

* linted config service

* linted git service

* linted input service

* linted types

* linted utils

* linted tests

* updated gitignore

* linted config.json

* added config initialization in runner (#282)

* added config initialization in runner

* bug fixes, shifted reflect-metadata import to individual runners since those are the actual entry point

* added test cases

* Update action-configuration.ts (#285)

* Checkout service (#286)

* added placeholder parser for definition file url

* added mapping to parsed node

* added definition file test cases to cli config

* updated config and input domain object

* added get source, target project in config service. update load git event and project config to consider case for branch flow

* added more test cases and updated old ones for config objects and services

* added clone to node object, added get source and target project to config service, validate start project

* added get flow type to config services

* clean up in loading git config

* changed hasPullRequest method

* added more functionality to config service to help with checkout service

* update eslint to ignore variables that begin with underscore

* implemented checkout service

* added test cases for checkout service

* updated package.json and lock file

* removed code smells

* added repository clone location to checkout info

* clean up of test data

* removed code duplication (#293)

* refactored checkout service and updated a test case (#292)

* Pre and post functionality  (#297)

* added pre and post services

* added test cases for  pre and post services

* updated test cases

* added test cases for getPre and getPost

* Archive service (#289)

* added placeholder parser for definition file url

* added mapping to parsed node

* added definition file test cases to cli config

* updated config and input domain object

* added get source, target project in config service. update load git event and project config to consider case for branch flow

* added more test cases and updated old ones for config objects and services

* added clone to node object, added get source and target project to config service, validate start project

* added get flow type to config services

* clean up in loading git config

* changed hasPullRequest method

* added more functionality to config service to help with checkout service

* update eslint to ignore variables that begin with underscore

* implemented checkout service

* added test cases for checkout service

* updated package.json and lock file

* removed code smells

* added repository clone location to checkout info

* clean up of test data

* added artifacts service

* refactored and added artifacts service

* added test cases for artifacts and upload service

* logged artifact upload results

* added requested change

* changed execute node chain argument from node to ExecutionNode (#300)

* changed execute node chain argument from node to ExecutionNode

* changed for loop for execute service

* changed node.map for execute service tests

* Prep flow (#298)

* added nodechain generator and its test cases. removed load definition file and generate place holders from base config

* added node field to checkedout node info. updated checkout service to use nodechain directly from config service

* renamed nodechain generator to definition file reader. added get definition file

* added test cases for get definition file

* refactored checkoutDefinitionTreeParallel

* Executor refactor (#304)

* changed excute result domain object to include no optional fields

* made get node command public, so that it can be used in printing execution plan. made changes as required by the changed execute result domain object

* updated test cases for executor service

* updated test cases according to the changed domain objects for executor service

* Artifact node chain (#305)

* changed artifact service to use node chain directly from config service

* updated test cases

* refactored artifact service

* updated test cases

* refactored getNodesToArchive

* Flow service (#306)

* added string representation of ExecutionResult

* added flow service

* added tests for flow service

* added FlowResult domain object

* lint fix

* bug fix while constructing NodeExecution array from CheckedOutInfo during a parallel checkout

* refactored flow

* more refactoring

* Job summary service (#307)

* pre-post services return their execution result

* added getEventUrl and getDefinitionFileUrl and updated test cases

* added job summary service

* added test cases for job summary

* fix in config service test cases

* added requested changes

* eslint: arrow-parens rule (#310)

* Runner setup (#312)

* added default flow result

* implemented runners and shifted execution to separate entry point file

* added test cases for runners

* updated package-lock.json

* updated package-lock.json

* resolve 14.x runner error

* added printing of execution failure

* configuration-reader to 3.0.0 (#318)

* @kie/build-chain-configuration-reader 3.0.4 (#321)

* updated domain objects to use Node from build-chain-config-reader

* updated artifact service to use domain objects directly from build-chain-config. passing project name as default artifact name

* updated test cases for artifact service

* updated checkout service to use domain objects directly from build-chain-config-reader

* updated command executor service to use domain objects directly from build-chain-config-reader

* updated configuration service to use domain objects directly from build-chain-config-reader

* removed code from definition file reader service which is now directly implemented by the build-chain-config-reader lib

* updated definition file reader tests

* updated tests to use domain objects directly from build-chain-config-reader

* removed custom types

* bumped up version of build-chain-config-reader to 3.0.4

* migrated mock-github poc to the actual mock-github (#322)

* e2e (#324)

* fixed action.yml

* updated .gitignore

* added scripts to build package, run e2e tests and updated dependencies

* made action argument a service and executed it in the action runner to parse input

* fixed bug in getting nodes to checkout and added artifact name validator

* improved logging in checkout service

* changed logging from info to debugging for regex-command-treatment

* getCloneUrl returns a path to the local repository when running e2e tests

* fixed bug in git version and clone

* improved error msg in getForkName

* configure octokit to use proxy if defined

* improved logging and annotations during flow execution

* improved logging for pre and post

* updated test cases

* added e2e tests for single pr flow

* fixed clone case

* added helper to enable disable easy logging

* added cross-pr tests

* updated dependencies file and single pr tests

* allow unrelated history merge

* updated gitignore and package.json

* added full downstream tests

* updated other e2e tests with comments and simplifications

* trimmed white spaces from additional-flag input

* added branch e2e tests

* added e2e pr checks

* increase test timeout limit

Co-authored-by: Github <noreply@github.com>

* Logger (#326)

* refactored logger to be a typedi service

* updated logger service for runners

* updated logger service for artifacts service

* updated logger service for checkout service

* updated logger service for command service

* updated logger service for config service

* updated logger service for flow service

* updated logger service for git services

* updated logger service for pre-post services

* updated logger util

* updated test cases

* fixed coverage script

* Cli args (#327)

* refactored cli arguments to typedi service

* updated runners

* updated test cases

* Octokit (#328)

* refactored octokit factory to typedi service

* updated config service

* updated github api service

* updated test cases

* CLI argument parsing bug fix (#329)

* placed the bash shebang in the correct entry point file

* fixed cli argument parsing

* updated test cases

* prepare for release, updated changelog, package.json, readme and minor changes

* fixed test case

* push compiled file for actions

Co-authored-by: Enrique Mingorance Cano <ginxaco@gmail.com>
Co-authored-by: Enrique Mingorance Cano <emingora@redhat.com>
Co-authored-by: Github <noreply@github.com>
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.

None yet

3 participants