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

Add GH actions to CI #383

Merged
merged 2 commits into from
Apr 23, 2020
Merged

Add GH actions to CI #383

merged 2 commits into from
Apr 23, 2020

Conversation

SilleBille
Copy link
Member

@SilleBille SilleBille commented Apr 22, 2020

This patch adds GH actions as part of the CI. This patch reuses scripts from travis/

Pros

  • A clean workflow: build -> test (ie) test only if build passes, unlike Travis where we execute same scripts in every job.
  • Removes dependency on Travis and transfer.sh service
  • Uploads rpms and logs as part of the CI workflow
  • Targets only master and gh-actions (will be removed in future) branches
  • Instead of one huge log console, every step is now readable. Search feature available for logs
  • Possibility to include multiple workflows, that execute in parallel. This patch uses only 1 workflow at the moment.
  • Possibility to exclude CI execution against certain files/dirs. Eg: commits to docs/ can be ignored.

Cons

Future improvements

  • Remove Travis from our CI and make GH actions as our primary upstream CI
  • Move linting/unit tests from rpm build to a separate job: lint -> unit test -> build -> functional test
  • Possibility for multi-node testing using service containers
  • Build container image using Docker container action and use it as the base image for service containers. Related question posted on GH community
  • Include downstream runners

This Patch:

- Adds Github Actions to CI
- reuses scripts under ./travis/ (requires improvement)
- Uploads artifacts to GH by removing dependency on transfer.sh
- Uploads built rpms (auto-deleted every 90 days)
- Runs build job on container provisioned by GH actions (ie)
  not necessary to meddle with docker/podman commands manually
- Run PKI test job on self-provisioned container (room for improvement
  by running on service containers by combining with Docker GH actions)

Signed-off-by: Dinesh Prasanth M K <dmoluguw@redhat.com>
@SilleBille SilleBille self-assigned this Apr 22, 2020
@SilleBille SilleBille added CI Continous Integration Enhancement New features and enhancements related to the product labels Apr 22, 2020
@SilleBille
Copy link
Member Author

Hmm. The new GH actions CI doesn't run in this repo until merged. But, you can browse through the CI job that ran in my personal repo: https://github.com/SilleBille/pki/actions/runs/84282813

@cipherboy
Copy link
Member

Security risks with downstream runners

I don't think we're really worried about that right now -- we're running on upstream (Azure hosted) hardware with this PR right?

Copy link
Contributor

@edewata edewata 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 it looks good, but please see my comments/questions below. Is there anything that we need to set up in order to run the GH actions in our own repo before submitting the PR? If so, could you please provide a link to the instruction? Thanks!

.github/workflows/required-tests.yml Show resolved Hide resolved
# run: docker exec -i ${CONTAINER} dnf copr enable -y ${COPR_REPO}

- name: Install DS
run: docker exec -i ${CONTAINER} ${PKIDIR}/travis/ds-create.sh
Copy link
Contributor

Choose a reason for hiding this comment

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

Eventually we want to run the test scripts from pki-tests package that we just built instead of from the source repository, but this is fine for now.

Copy link
Member Author

Choose a reason for hiding this comment

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

Right. Currently, I used the existing scripts. Since the artifacts are shared, it is possible to use the tests from the pki-tests package

.github/workflows/required-tests.yml Show resolved Hide resolved
travis/runner-init.sh Show resolved Hide resolved
run: docker exec -i ${CONTAINER} bash -c "journalctl -u pki-tomcatd@pkitest > /var/log/pki/pki-journalctl.log"

- name: Compress logs
if: always()
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious, what is the purpose of if: always()?

Copy link
Member Author

Choose a reason for hiding this comment

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

always() makes sure that this step gets executed even if any of the previous step fails. By default, all the steps after a failed step are skipped. In future, we can change this to failure() which will run only when one of the previous step fails. More information

.github/workflows/required-tests.yml Outdated Show resolved Hide resolved
run: docker exec -i ${CONTAINER} ${PKIDIR}/travis/ds-create.sh

- name: Install CA
run: docker exec -i ${CONTAINER} ${PKIDIR}/travis/ca-create.sh
Copy link
Contributor

Choose a reason for hiding this comment

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

If the installation fails we have code in ca-create.sh to upload the logs to transfer.sh for troubleshooting. Can that code be changed to upload to GH instead eventually?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. That's possible and easier too.

Since this patch uploads all the logs in /var/log/pki, we can do a minor change in future to [subsystem]-create.sh:
SYSTEMD_LOG=/var/log/pki/pkitest-systemd-[subsystem].log

FWIW, this patch includes PKI journalctl logs as an artifact

.github/workflows/required-tests.yml Show resolved Hide resolved
PKIDIR: /tmp/workdir/pki
LOGS: ${GITHUB_WORKSPACE}/logs.txt
COPR_REPO: "@pki/master"
test_set: "test_caacl_plugin.py test_caacl_profile_enforcement.py test_cert_plugin.py test_certprofile_plugin.py test_ca_plugin.py test_vault_plugin.py"
Copy link
Contributor

Choose a reason for hiding this comment

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

Since the build is now only done once, maybe we can split some of the IPA tests to run concurrently to reduce the execution time.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, that's possible too \o/ May be in a future PR?

@bhavikbhavsar
Copy link
Contributor

For the tests after installation can we verify if the services ca, kra, etc are running?

@SilleBille
Copy link
Member Author

I don't think we're really worried about that right now -- we're running on upstream (Azure hosted) hardware with this PR right?

@cipherboy yes, this patch runs on Github provided runners

For the tests after installation can we verify if the services ca, kra, etc are running?

@bhavikbhavsar This patch does the same thing as we do in Travis (in fact, uses the same scripts). Going forward, I'll be working with @06shalini to run actual test playbooks.

This commit:

- Adds IPA tests to the GH actions matrix
- Gathers logs of IPA and PKI and corresponding journalctl
  logs and uploads it as a GH action artifact
- Minor cleanups to previous jobs

Signed-off-by: Dinesh Prasanth M K <dmoluguw@redhat.com>
Copy link
Contributor

@edewata edewata left a comment

Choose a reason for hiding this comment

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

LGTM

@SilleBille SilleBille merged commit 7af607b into dogtagpki:master Apr 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI Continous Integration Enhancement New features and enhancements related to the product
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants