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

[Build] Add Github workflows #9490

Closed
wants to merge 1 commit into from
Closed

Conversation

ktmud
Copy link
Member

@ktmud ktmud commented Apr 8, 2020

CATEGORY

  • Build / Development Environment

SUMMARY

Adding GitHub Actions per discussion in #9481. It is a pure addition to current build process for now. Nothing changes for Travis CI, except Cypress is upgraded from 3.6.1 to 4.3.0.

We may evaluate whether to disable Travis CI once GitHub Actions become more stable.

Jobs are split into 3 workflows to maximize parallelization:

  • superset-python.yml: python lint and unit tests
  • superset-frontend.yml: frontend lint and unit tests
  • superset-e2e.yml: end to end tests with Cypress

A custom GitHub Action was created to generalize some of the building steps, but not all of them. There are duplicate code about cache across files, while could potentially be lifted into the GitHub Action like the official Cypress GitHub action.

Some thoughts

GitHub Actions is less powerful than some other CI/CD tools, e.g., CircleCI and GitLab CI/CD, but overall it was a pleasant experience to use. Two major nuances are: 1. limited parallelization support, cannot organize jobs as DAGs; 2. cannot automatically cancel current jobs on new pushes.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

image

TEST PLAN

Make sure CI check pass.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Changes UI
  • Requires DB Migration.
  • Confirm DB Migration upgrade and downgrade tested.
  • Introduces new feature or API
  • Removes existing feature or API

REVIEWERS

@john-bodley @dpgaspar @mistercrunch @craig-rueda

@ktmud
Copy link
Member Author

ktmud commented Apr 8, 2020

See the builds in action: ktmud#25

Copy link
Member

@dpgaspar dpgaspar left a comment

Choose a reason for hiding this comment

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

First pass

pull_request:
paths:
- superset/**/*.py
- tests/**
Copy link
Member

Choose a reason for hiding this comment

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

Should this include superset-frontend/** ?

Copy link
Member Author

Choose a reason for hiding this comment

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

This file is purely for python code. Frontend code checks are done in other workflows. Maybe I this rename this file to avoid confusion.

@craig-rueda
Copy link
Member

Looks good - have you thought about Circle?

@ktmud
Copy link
Member Author

ktmud commented Apr 8, 2020

CircleCI was my first choice, but it seems there are some administration overheads involved in setting it up and no other Apache projects are using it AFAIK.

@codecov-io
Copy link

codecov-io commented Apr 9, 2020

Codecov Report

Merging #9490 into master will not change coverage by %.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #9490   +/-   ##
=======================================
  Coverage   58.77%   58.77%           
=======================================
  Files         385      385           
  Lines       12239    12239           
  Branches     3022     3022           
=======================================
  Hits         7193     7193           
  Misses       4862     4862           
  Partials      184      184           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5565895...282b39e. Read the comment docs.

@ktmud ktmud force-pushed the github-actions branch 5 times, most recently from 04fd288 to fd5c4ec Compare April 9, 2020 07:39
Copy link
Member Author

@ktmud ktmud left a comment

Choose a reason for hiding this comment

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

I think this is ready for another review. Everything finally works!

description: additional commands to run
parallel:
required: false
description: whether to run additional commands in parallel
Copy link
Member Author

Choose a reason for hiding this comment

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

The parallel mode is not currently in use.

redis:
image: redis:5-alpine
ports:
- 16379:6379
Copy link
Member Author

Choose a reason for hiding this comment

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

GitHub-hosted action runners have some softwares pre-installed, including MySQL, Redis, and PostgreSQL.

Here we map all database services to a new port to make sure we don't accidentally use the build-in services that may be running on default ports already.

path: |
~/.npm
superset-frontend/.terser-plugin-cache/
key: ${{ runner.os }}-npm-${{ hashFiles('superset-frontend/package-lock.json') }}
Copy link
Member Author

Choose a reason for hiding this comment

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

Cypress plugin will handle its own cache. So not need to add cypress-base/package-lock.json as hash key.

wait-on: http://localhost:8081
wait-on-timeout: 10
spec: cypress/integration/*/*
record: true
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm enabling recording as it's free anyway. Check the recorded logs here.

@@ -0,0 +1 @@
cypress/screenshots/
Copy link
Member Author

Choose a reason for hiding this comment

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

Local builds may generate this folder.

"video": false,
"videoUploadOnPasses": false,
"viewportWidth": 1280,
"viewportHeight": 800,
"requestTimeout": 10000
Copy link
Member Author

Choose a reason for hiding this comment

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

The original config has duplicate requestTimeout.

"video": false,
"videoUploadOnPasses": false,
"viewportWidth": 1280,
"viewportHeight": 800,
"requestTimeout": 10000
"projectId": "dk2opw"
Copy link
Member Author

@ktmud ktmud Apr 9, 2020

Choose a reason for hiding this comment

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

Updated to a project under my personal account for testing. Will need to change back to the official project once merged.

Someone with admin access on GitHub please add a new record key to GitHub Actions secrets under the name CYPRESS_RECORD_KEY.

@@ -75,7 +75,7 @@ export default () =>
.trigger('mousedown', { which: 1 })
.trigger('dragstart', { dataTransfer })
.trigger('drag', {});
cy.get('.grid-content .dragdroppable')
cy.get('.grid-content div.grid-row.background--transparent')
Copy link
Member Author

Choose a reason for hiding this comment

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

The upgraded Cypress will error out because it was dragged to a zero-height element. This fixes the error by dragging to the last visible row instead of the invisible one.

Copy link
Member Author

@ktmud ktmud left a comment

Choose a reason for hiding this comment

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

Updated the Cypress test cases even more.

@@ -1,13 +1,14 @@
{
"baseUrl": "http://localhost:8081",
"chromeWebSecurity": false,
"defaultCommandTimeout": 20000,
Copy link
Member Author

Choose a reason for hiding this comment

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

No need to actually wait for 20s for default commands (e.g., click triggers).

cy.wait('@boxplotRequest');
cy.get('.grid-container .box_plot').should('be.exist');
// wait for box plot to appear
cy.get('.grid-container .box_plot');
Copy link
Member Author

Choose a reason for hiding this comment

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

A simple get will wait for the element to appear. No need to wait for the additional request.

const responseBody = await readResponseBlob(xhr.response.body);
expect(responseBody).to.have.property('error', null);
const sliceId = responseBody.form_data.slice_id;
cy.get(`#chart-id-${sliceId}`).should('be.visible');
Copy link
Member Author

Choose a reason for hiding this comment

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

Has to return a Promise for the test cases to be captured.

cy.route('POST', boxplotRequest).as('boxplotRequest');
cy.wait('@boxplotRequest');
cy.get('.grid-container .box_plot').should('be.exist');
cy.get('.grid-container .box_plot', { timeout: 5000 }); // wait for 5 secs
Copy link
Member Author

Choose a reason for hiding this comment

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

Again, a simple get will wait. Also, dashboardId may be out of sync when test cases are running in parallelized mode.

cy.on('fail', err => {
expect(err.message).to.include('Timed out retrying');
expect(err.message).to.include('timed out waiting');
Copy link
Member Author

Choose a reason for hiding this comment

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

The error message changed in Cypress v4.

@ktmud ktmud force-pushed the github-actions branch 14 times, most recently from d25aed5 to 5114064 Compare April 9, 2020 20:32
@ktmud ktmud force-pushed the github-actions branch 4 times, most recently from 288e466 to bf3288e Compare April 9, 2020 21:54
cy.get('.chart-container .header_line');
cy.get('.chart-container .subheader_line');
cy.get('.chart-container .header-line');
cy.get('.chart-container .subheader-line');
Copy link
Member Author

Choose a reason for hiding this comment

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

explore/visualizations/index.test.js was probably unintentioally disabled by #6241 .

It has since stopped running for over a year now. A lot of these tests are now broken. It's easy to add them back, but we may want to do the fix in another PR. Keep the changes for BigNumber here just for reference.

As an replacement for Travis CI.
@ktmud
Copy link
Member Author

ktmud commented Apr 9, 2020

Woking on further improvements, closing for now to avoid excessive notification.

@ktmud ktmud closed this Apr 9, 2020
@willbarrett
Copy link
Member

Hey @ktmud - let us know if there's anything we at Preset can do to support you on this work. We're really feeling the Travis pain and want to help get to a solution.

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.

5 participants