Skip to content

Run tests via GitHub Actions#5201

Merged
westonruter merged 60 commits intodevelopfrom
add/test-workflow
Nov 7, 2020
Merged

Run tests via GitHub Actions#5201
westonruter merged 60 commits intodevelopfrom
add/test-workflow

Conversation

@pierlon
Copy link
Contributor

@pierlon pierlon commented Aug 9, 2020

Summary

Migrates all lint and test jobs from Travis to GHA.

Checklist

  • My pull request is addressing an open issue (please create one otherwise).
  • My code is tested and passes existing tests.
  • My code follows the Engineering Guidelines (updates are often made to the guidelines, check it out periodically).
@google-cla google-cla bot added the cla: yes Signed the Google CLA label Aug 9, 2020
@pierlon pierlon changed the title Run tests via GitHub Actions Aug 9, 2020
@pierlon pierlon force-pushed the add/test-workflow branch 2 times, most recently from b5e757e to 6714969 Compare August 11, 2020 16:54
@github-actions
Copy link
Contributor

github-actions bot commented Aug 11, 2020

Plugin builds for 9568f67 are ready 🛎️!

@pierlon pierlon added the WS:Core Work stream for Plugin core label Aug 12, 2020
@pierlon pierlon marked this pull request as draft August 13, 2020 07:49
@pierlon pierlon changed the title [WIP] Run tests via GitHub Actions Aug 13, 2020
@CLAassistant
Copy link

CLAassistant commented Oct 8, 2020

CLA assistant check
All committers have signed the CLA.

@pierlon pierlon force-pushed the add/test-workflow branch 4 times, most recently from cddb1c6 to 2df4fe7 Compare October 25, 2020 08:28
@pierlon pierlon added Testing Issues related with Unit, E2E, Smoke, and other testing requirements/needs Infrastructure Changes impacting testing infrastructure or build tooling labels Oct 25, 2020
@pierlon pierlon self-assigned this Oct 25, 2020
@pierlon pierlon added this to the v2.1 milestone Oct 25, 2020
@pierlon pierlon marked this pull request as ready for review October 25, 2020 08:59
Copy link
Contributor

@johnwatkins0 johnwatkins0 left a comment

Choose a reason for hiding this comment

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

@pierlon This is very impressive. My review mainly consists of questions rather than requests for changes. It looks like it's all working, which is awesome.

run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Set up tests
# TODO: Add step to install plugins instead of relying on .dev-lib
Copy link
Contributor

Choose a reason for hiding this comment

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

Correct me if I'm wrong, but couldn't we do this now by moving the code from .dev-lib into install-wp-tests.sh? It seems like this PR gets us 90% of the way toward removing the wp-dev-lib dependency. Can we get to 100%?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question. The original intention was to remove the wp-dev-lib dependency but I realized it is being used for generating the readme (@westonruter any other uses I'm missing?) which also relies on the .dev-lib file, so I didn't spend much time looking into migrating the installation of the plugins just yet. I suppose that still can be done and then we could leave the .dev-lib file in place until all use cases for it are migrated.

@@ -0,0 +1,64 @@
name: External Libraries
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious, why are these tests in a separate configuration? Shouldn't these also depend on the preceding linting/testing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Technically these libs aren't apart of the plugin so these tests shouldn't be impeded by the plugin's lint/tests jobs (unless I'm missing something here).

/cc @schlessera

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm currently working on extracting these libraries out (https://github.com/ampproject/amp-toolbox-php), so we shouldn't waste too much thought on these. I will rebuild GHA testing on that other repo.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The tests are already running on the other repository now:
Image 2020-10-29 at 5 16 52 PM

So there's no need to do any work on them here anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Awesome! WIll remove the workflow then.

@pierlon
Copy link
Contributor Author

pierlon commented Oct 27, 2020

The current approach here is to run lint jobs first, then if those succeed it moves on to running the tests, then it builds the plugin for deployment to GCS and finally comments on the PR with links for downloading those builds. One major drawback with this approach is that if any of these jobs fail for whatever reason, the whole workflow has to be re-run (i.e. if a test job fails, all lint jobs have to be re-run irregardless of their outcome).

The only alternative I see so far is to split the relevant jobs into separate workflows. That allows for easier re-run of jobs if they fail, but it also means that all jobs would be running in parallel as there is currently no way for separate workflows to depend on one another (i.e. all workflows would be running in parallel).

Any thoughts on this? Should we keep the linear approach and have one workflow with all the jobs, or split the relevant jobs in different workflows and have all the jobs run asynchronously to allow for easier re-run of failed jobs?

@johnwatkins0
Copy link
Contributor

johnwatkins0 commented Oct 28, 2020

if any of these jobs fail for whatever reason, the whole workflow has to be re-run

@pierlon Do you mean in the case that some technical issue in the action itself causes the build to stop? I don't think we would expect that case to happen frequently, right? In that case, it might be annoying to have to restart the entire process when the failure was extrinsic to the code change, but it would also indicate to us that the action workflow might not be stable enough and may need attention, which is useful.

To me it makes sense to have all the jobs that depend on each other run in sequence, with the entire sequence needing to start over if linting or tests fail.

@pierlon
Copy link
Contributor Author

pierlon commented Oct 28, 2020

Do you mean in the case that some technical issue in the action itself causes the build to stop?

@johnwatkins0 Yep that's what I meant. That would also include flaky tests we sometimes encounter, but yes those should be happening quite infrequently from now on.

I also prefer having the jobs run in sequence, but just wanted to make it known that the inability to re-run a separate job is currently not a feature on GHA.

@pierlon
Copy link
Contributor Author

pierlon commented Nov 3, 2020

⚠️ Rebasing with latest changes from develop.

@pierlon pierlon requested a review from johnwatkins0 November 7, 2020 11:40
Copy link
Member

@westonruter westonruter left a comment

Choose a reason for hiding this comment

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

Amazing work. You are a GitHub Action whisperer. Just a couple questions:

${{ runner.os }}-npm-

- name: Install Node dependencies
run: npm ci
Copy link
Member

Choose a reason for hiding this comment

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

Comment on lines +164 to +165
needs:
- lint-js
Copy link
Member

Choose a reason for hiding this comment

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

Why do JS unit tests depend on linting?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This can be removed as well.

Comment on lines +204 to +205
needs:
- lint-js
Copy link
Member

Choose a reason for hiding this comment

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

Why do E2E tests depend on linting?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No definitive reason, this can be removed.

Comment on lines +276 to +278
needs:
- lint-php
- static-analysis-php
Copy link
Member

Choose a reason for hiding this comment

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

Why does PHPUnit depend on linting and static analysis?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This can be removed as well.

Copy link
Contributor Author

@pierlon pierlon left a comment

Choose a reason for hiding this comment

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

Thanks @westonruter. See 9568f67 for the amendments made.

Comment on lines +204 to +205
needs:
- lint-js
Copy link
Contributor Author

Choose a reason for hiding this comment

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

No definitive reason, this can be removed.

Comment on lines +276 to +278
needs:
- lint-php
- static-analysis-php
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This can be removed as well.

Comment on lines +164 to +165
needs:
- lint-js
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This can be removed as well.

Copy link
Member

@westonruter westonruter left a comment

Choose a reason for hiding this comment

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

I can't claim to certify all the GH Action code, but it looks good to me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes Signed the Google CLA Infrastructure Changes impacting testing infrastructure or build tooling Testing Issues related with Unit, E2E, Smoke, and other testing requirements/needs WS:Core Work stream for Plugin core

5 participants