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

Cypress on GitHub Actions #378

Merged
merged 11 commits into from
May 12, 2021
Merged

Cypress on GitHub Actions #378

merged 11 commits into from
May 12, 2021

Conversation

himdel
Copy link
Collaborator

@himdel himdel commented Apr 30, 2021

Fixes https://issues.redhat.com/browse/AAH-529

This adds a Cypress workflow to github actions, configured to:

  • allow to be triggered manually on a specific branch
  • run on push to master, stable-4.2 and stable-4.3 (stable-* really)
  • run on PRs against those same branches
  • run daily on master

The workflow is using the Pulp in One Container images, big thanks to @fao89 for getting these running. (More docs.)

  • we build our own version of https://github.com/pulp/pulp-oci-images/blob/latest/pulp_galaxy_ng/Containerfile changed to download galaxy_ng master (or other branch, see below) and remove conflicting versions of dependencies.
  • then we build ansible-hub-ui using build-standalone, and move those files to replace the original static UI files in the container
  • Cypress is running outside the container, connecting to localhost:8002/api/galaxy

Branches:

  • for a PR from pr_branch against ansible-hub-ui base:
    checking out ansible-hub-ui@pr_branch
    BRANCH=refs/heads/base
    SHORT_BRANCH=base
    pip install ...galaxy_ng@base

  • for a branch push on ansible-hub-ui:
    checking out ansible-hub-ui@branch
    BRANCH=refs/heads/branch
    SHORT_BRANCH=branch
    pip install ...galaxy_ng@branch

  • for manual builds, branch is whatever the user chooses, for cron builds it's master

Caching:

Artifacts:

on failure, we upload cypress/screenshots and cypress/videos
(example: https://github.com/himdel/ansible-hub-ui/actions/runs/797934949)

Timing:

  • ~8 minutes total when using cache, ~12 when rebuilding container
  • ~3 minutes of that is webpack
  • Cypress runs under 3 minutes

Cc @newswangerd

push:
branches: [ $default-branch stable-* ]
# daily on $default-branch
schedule:
Copy link
Member

Choose a reason for hiding this comment

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

is a daily job necessary? We should be pretty well covered with branch and push builds

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Definitely not necessary :)

Pretty much the only use for a scheduled job in our circumstances is to check that the latest galaxy_ng changes don't break our UI.

So, I think it has some value, but maybe not quite daily?
What about weekly?

Copy link
Member

@newswangerd newswangerd left a comment

Choose a reason for hiding this comment

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

Love it

@newswangerd newswangerd added backport-4.2 This PR should be backported to stable-4.2 (1.2) backport-4.3 This PR should be backported to stable-4.3 (2.0) labels Apr 30, 2021
@newswangerd
Copy link
Member

I assume this can be backported to 4.2 and 4.3, right?

podman run \
--detach \
--publish 8002:80 \
Copy link
Member

Choose a reason for hiding this comment

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

FYI: we are planning to change the container to use https:
pulp/pulp-oci-images#73
In the future you may need to:

Suggested change
--publish 8002:80 \
--publish 8002:443 \

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@fao89 could that be implemented as an optional setting?

I don't really see any value in generating a self-signed certificate, using it on the webserver, and running cypress in "ignore SSL certificates" mode or having to copy the certificate there, just so https works in a way that http already does.

We can probably work around that on our side, but if that feature could be made optional, it may be preferrable :). Thanks :).

Copy link
Member

@fao89 fao89 May 10, 2021

Choose a reason for hiding this comment

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

yes, we are discussing two options now:

  • tag latest: https; tag nossl: http
  • tag latest: http; tag https: https

so if we make latest defaults to https, it is just a matter of using nossl tag
I'll keep you informed, but if you want to follow the discussion, it is happening on pulp-dev:
https://listman.redhat.com/archives/pulp-dev/2021-May/msg00008.html

working-directory: 'pulp_galaxy_ng'
run: |
echo '\
FROM docker.io/pulp/pulp-ci-centos:latest
Copy link
Member

Choose a reason for hiding this comment

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

you can test the https container version by using

Suggested change
FROM docker.io/pulp/pulp-ci-centos:latest
FROM docker.io/pulp/pulp-ci-centos:https

@unlikelyzero
Copy link

unlikelyzero commented May 3, 2021

@himdel @newswangerd @calvin hello from the other side! I went snooping for an example of the github codecov integration and stumbled into this PR :)

Please ping @tiago, @apurva, and @brum on the Ansible team. We had been using Cypress with Github Actions for a few months and I think it would be great to collaborate on some common tooling or at least get contextual PR review. Also, Apurva on the AA team may be taking over aap-visual which has some examples here https://github.com/unlikelyzero/aap-visual/blob/main/.github/workflows/nightly.yml

Specifically, I'd get feedback on the utility of adhoc job execution and inline Cypress Dashboard reporting

@himdel
Copy link
Collaborator Author

himdel commented May 10, 2021

I assume this can be backported to 4.2 and 4.3, right?

Definitely, all the branch logic should be using the base branch of a PR, or the branch it was pushed to, so this should work for all the versions. 👍

(Not sure the non-master branches are currently passing, but we can fix any tests/failures when backporting.)

@himdel
Copy link
Collaborator Author

himdel commented May 10, 2021

@unlikelyzero Welcome, well, any reviews are certainly appreciated :)

I'm not sure there's much overlap with other projects not based on pulp, or projects not using a split repo ui-api approach, as the bulk is about building and configuring a container, but if you have any ideas, feel free to share :).

cypress-io/github-action@v2 looks interesting, though it seems we'd have to get rid of the ansible-hub-ui/test/ split in favor of having cypress+dependencies in the repo root, so definitely a separate PR.

Inline reporting defintiely looks useful, I'll look into that in a separate PR, at this point I'm not ever sure how the reporting will look without it. (The config doesn't seem to do anything related to inline reporting, so it looks like maybe the cypress action is trying to do too many things.)

(I'm not sure what you mean by ad-hoc execution, but we mostly just need this to run on PRs.)

@unlikelyzero
Copy link

@himdel nothing to add in terms of approach. This is awesome.
The ansible/tower-qa is using a split repo approach as it is a private repo testing the ansible/awx repo, so it is similar.

The main reason that I mentioned inline reporting is that you can avoid storing test results and videos as CI artifacts. Definitely not specific to this PR; it's something which must be configured by a repo admin on github, itself.

The tower-qa repo needed to have an "ad-hoc" workflow file which was separate from the "per PR" workflow file. I'd check in with that team to learn more.

Anyways, glad to see GHA + Cypress being used together :)

@himdel himdel merged commit 6a5688e into ansible:master May 12, 2021
@himdel himdel deleted the cypress-gha branch May 12, 2021 14:12
@patchback
Copy link

patchback bot commented May 12, 2021

Backport to stable-4.2: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-4.2/6a5688eb96f9f889e93b9e1b55dee8ada480de06/pr-378

Backported as #430

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

patchback bot pushed a commit that referenced this pull request May 12, 2021
* workflows: manual cypress test, initial version

* Switch to pulp-oci-images

* Override pulp-galaxy-ng pip versions

to be able to install master galaxy_ng without conflicts

* Configure and run pulp/pulp

* Own Containerfile, reset password

replaces https://github.com/pulp/pulp-oci-images/blob/latest/pulp_galaxy_ng/Containerfile

* switch to /api/galaxy, 8002

* use buildah & podman, no sudo needed for UI replace

* upload on failure

* cache ~/.npm, Cypress; cache container image, only build if galaxy_ng changed, else load

and use podman repo prefixes

* cleanup: kill container

* cleanup, rename workflow to cypress

(cherry picked from commit 6a5688e)
@patchback
Copy link

patchback bot commented May 12, 2021

Backport to stable-4.3: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-4.3/6a5688eb96f9f889e93b9e1b55dee8ada480de06/pr-378

Backported as #431

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

patchback bot pushed a commit that referenced this pull request May 12, 2021
* workflows: manual cypress test, initial version

* Switch to pulp-oci-images

* Override pulp-galaxy-ng pip versions

to be able to install master galaxy_ng without conflicts

* Configure and run pulp/pulp

* Own Containerfile, reset password

replaces https://github.com/pulp/pulp-oci-images/blob/latest/pulp_galaxy_ng/Containerfile

* switch to /api/galaxy, 8002

* use buildah & podman, no sudo needed for UI replace

* upload on failure

* cache ~/.npm, Cypress; cache container image, only build if galaxy_ng changed, else load

and use podman repo prefixes

* cleanup: kill container

* cleanup, rename workflow to cypress

(cherry picked from commit 6a5688e)
@himdel
Copy link
Collaborator Author

himdel commented May 12, 2021

(Removed backport labels because there's nothing to backport, github uses the master branch to get the workflow, regardless of the branch being tested)

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

4 participants