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

Refactor lint-test.yaml GHA Workflow to use a matrix for test job generation; Add nginx.enabled and hpa.enabled tests #598

Merged
merged 1 commit into from
Jul 24, 2024

Conversation

jessebot
Copy link
Collaborator

@jessebot jessebot commented Jul 23, 2024

Description of the change

  • updates the test jobs to be generated from a strategy.matrix
  • adds job to matrix to run a test of chart with nginx.enabled=true and image.flavor=fpm both set
  • adds job to matrix to run a test of chart with hpa.enabled=true set

Benefits

  • New tests are easier to add :)

  • Now if anyone would like to change a config file or other template that seems like it could affect users that use the nginx.enabled parameter, this PR will do the bare minimum testing for that.

Possible drawbacks

None that I can think of, but I'm also open to feedback :)

Applicable issues

Not sure if we have any issues related to this 🤔 This is just something we've talked about several times.

Checklist

@jessebot jessebot added 3. to review Waiting for reviews nginx container issues related to the nginx container bundling in the nextcloud pod. labels Jul 23, 2024
@jessebot jessebot self-assigned this Jul 23, 2024
@provokateurin
Copy link
Member

How about starting to use a matrix for all these test? Currently the jobs all are almost the same, except for the chart configuration. This would make it a lot easier to add new tests and it's also more maintainable.

@jessebot
Copy link
Collaborator Author

jessebot commented Jul 23, 2024

How about starting to use a matrix for all these test? Currently the jobs all are almost the same, except for the chart configuration. This would make it a lot easier to add new tests and it's also more maintainable.

I'm not against it, but we'd have to do a bunch of conditionals for the actual install step like this one:

      - name: Run chart-testing (install with nginx.enabled)
        id: install
        if: steps.list-changed.outputs.changed == 'true'
        run: |
            ct install --target-branch ${{ github.event.repository.default_branch }} \
            --helm-extra-set-args "--set=image.flavor=fpm --set=nginx.enabled=true"

I think we would be able to do something like if: matrix.test_case == 'nginx' here? 🤔 I would have to look up the exact syntax, but I'm happy to give it a shot :)

@provokateurin
Copy link
Member

But those arguments would just be part of the matrix

@jessebot
Copy link
Collaborator Author

oooooooo! Smart! Ok, yeah, I'll get something together in a bit and ping you again to take a look :)

@jessebot jessebot marked this pull request as draft July 23, 2024 12:38
@jessebot jessebot changed the title adds GitHub action to run a test of chart with nginx.enabled on all PRs Refactor lint-test.yaml GHA Workflow to use a matrix for test jobs and run a test of chart with nginx.enabled on all PRs Jul 23, 2024
@jessebot jessebot changed the title Refactor lint-test.yaml GHA Workflow to use a matrix for test jobs and run a test of chart with nginx.enabled on all PRs Refactor lint-test.yaml GHA Workflow to use a matrix for test jobs and add nginx.enabled test Jul 23, 2024
@jessebot jessebot force-pushed the add-nginx-testing branch from 141f874 to 6bf385e Compare July 23, 2024 12:57
@jessebot
Copy link
Collaborator Author

@provokateurin ok, now you can give it a look. I found the files tab of the PR hard to look at, so it might make more sense to check the file directly? links to import bits:

run-tests:
runs-on: ubuntu-22.04
needs: [changes, lint]
if: needs.changes.outputs.src != 'false'
strategy:
matrix:
test_case:
# test the plain helm chart with nothing changed
- test_case: 'Default - no custom values'
# test the helm chart with postgresql subchart enabled
- test_case: PostgreSQL Enabled
helm_args: '--helm-extra-set-args "--set=postgresql.enabled=true --set=postgresql.global.postgresql.auth.password=testing123456 --set=internalDatabase.enabled=false --set=externalDatabase.enabled=True --set=externalDatabase.type=postgresql --set=externalDatabase.password=testing12345"'
# test the helm chart with nginx container enabled
- test_case: Nginx Enabled
helm_args: '--helm-extra-set-args "--set=image.flavor=fpm --set=nginx.enabled=true"'
# test the helm chart with horizontal pod autoscaling enabled
- test_case: Horizontal Pod Autoscaling Enabled
helm_args: '--helm-extra-set-args "--set=image.flavor=fpm --set=nginx.enabled=true"'

- name: Run chart-testing (install ${{ matrix.test_case }})
id: install
if: steps.list-changed.outputs.changed == 'true'
run: |
if [[ ${{ matrix.test_case }} == 'Default - no custom values' ]]; then
ct install --target-branch ${{ github.event.repository.default_branch }}
else
ct install --target-branch ${{ github.event.repository.default_branch }} ${{ matrix.helm_args }}
fi

@jessebot jessebot marked this pull request as ready for review July 23, 2024 13:29
@jessebot
Copy link
Collaborator Author

We could merge this, then I can rebase the hpa PR and add its test the same way, so that way we can get some immediate testing of it all?

@jessebot
Copy link
Collaborator Author

oh wait, you'd need to change the required tests again to be run-tests. That's why the checks are upset, I think.

@jessebot jessebot added the CI/CD Anything to do with continuous integration or continuous deployment or release automation. label Jul 23, 2024
@jessebot jessebot requested a review from provokateurin July 23, 2024 14:14
@jessebot jessebot force-pushed the add-nginx-testing branch from 8d85fc9 to 17f6a62 Compare July 23, 2024 14:25
@jessebot jessebot requested a review from provokateurin July 23, 2024 14:27
.github/workflows/lint-test.yaml Outdated Show resolved Hide resolved
.github/workflows/lint-test.yaml Outdated Show resolved Hide resolved
jessebot added a commit to jessebot/nextcloud-helm that referenced this pull request Jul 23, 2024
Copy link
Member

@provokateurin provokateurin left a comment

Choose a reason for hiding this comment

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

Awesome, seems to work ❤️

Please remove the test commit and then I will change the settings to allow this to be merged

@jessebot jessebot force-pushed the add-nginx-testing branch from 61c10dd to 82589b7 Compare July 23, 2024 14:59
@provokateurin
Copy link
Member

Maybe also squash the commits, then the history is a bit cleaner

@provokateurin
Copy link
Member

I hope this works now, maybe I have to adjust the settings to require the individual jobs.

@jessebot
Copy link
Collaborator Author

Ok, I made it all one commit, however, I just noticed something off 🤔

All the jobs generated on my last commit test commit have weird names:
https://github.com/nextcloud/helm/actions/runs/10061297081

for instance the postgres job here is called:
[run-tests (PostgreSQL Enabled, --helm-extra-set-args "--set=postgresql.enabled=true --set=postgre...](https://github.com/nextcloud/helm/actions/runs/10061297081/job/27811245781#logs)

The actual args didn't template here either 😞 :
https://github.com/nextcloud/helm/actions/runs/10061297081/job/27811245781#step:8:1

@provokateurin
Copy link
Member

Yeah that is automatic from the matrix, nothing we can do about

@provokateurin
Copy link
Member

Alright I have to require all matrix tests individually

@jessebot jessebot added 4. to release Ready to be released and/or waiting for tests to finish and removed 3. to review Waiting for reviews labels Jul 23, 2024
.github/workflows/lint-test.yaml Outdated Show resolved Hide resolved
.github/workflows/lint-test.yaml Outdated Show resolved Hide resolved
@provokateurin
Copy link
Member

Some more testing of this PR would be nice:

  • No changes
  • Valid changes
  • Invalid changes
    Just to be sure we don't end up with broken CI afterwards.

@jessebot
Copy link
Collaborator Author

Some more testing of this PR would be nice:

* No changes

* Valid changes

* Invalid changes
  Just to be sure we don't end up with broken CI afterwards.
  1. No changes would be the current state it's in, but it still needs you to re-require the summary job, I think?

  2. valid changes can be tested after we fix the required jobs and we'll do the same test commit again?

  3. invalid changes are harder to test, but I'm open to suggestions 🤷

@provokateurin
Copy link
Member

I think invalid changes you can just force by breaking the yaml syntax, then the tests should definitely fail

@jessebot
Copy link
Collaborator Author

I think invalid changes you can just force by breaking the yaml syntax, then the tests should definitely fail

I can try that, but it might be caught by the lint before it gets to actually running the other jobs 🤔 We'll try after valid changes though 🫡

@provokateurin
Copy link
Member

Or you can change the image tag to some version that doesn't exist, then the lint will pass but the tests won't

@jessebot
Copy link
Collaborator Author

jessebot commented Jul 23, 2024

ok, lit, the no changes is completely valid, finally!
https://github.com/nextcloud/helm/actions/runs/10062423969/job/27814902243

I will push up a test commit that should be valid for the second wave of tests :)

@jessebot
Copy link
Collaborator Author

They all failed on creating the kind cluster? 🤔 could this be because we changed the runs-on?

@provokateurin
Copy link
Member

Yeah, it could be that this doesn't work on the self-hosted runners. Just change the tests back to the previous runs-on and we should be good.

@jessebot
Copy link
Collaborator Author

jessebot commented Jul 23, 2024

Looks like it works with a valid change 👍 (bump chart version and remove an empty commented line in values.yaml):
https://github.com/nextcloud/helm/actions/runs/10062658048/job/27815741344?pr=598#step:8:1

I will now to try to make an invalid change, by changing the image.tag to testing123.

@jessebot jessebot changed the title Refactor lint-test.yaml GHA Workflow to use a matrix for test jobs and add nginx.enabled test Refactor lint-test.yaml GHA Workflow to use a matrix for test job generation; Add nginx.enabled and hpa.enabled tests Jul 23, 2024
@provokateurin
Copy link
Member

We should set fail-fast: false on the matrix so that one failed job doesn't kill the other jobs (which might work just fine).

@jessebot
Copy link
Collaborator Author

Okay, so for invalid change, the first test failed expectedly:
https://github.com/nextcloud/helm/actions/runs/10063299174/job/27817817944?pr=598#step:8:129

However, unexpectedly, the rest were canceled 🤷 I guess they were all gonna fail the same way anyway, but I would have expected the other jobs to start, unless they were canceled by a maintainer or member? Do we want to do further testing of this, or would you say we're good to go on testing for now?

@jessebot
Copy link
Collaborator Author

We should set fail-fast: false on the matrix so that one failed job doesn't kill the other jobs (which might work just fine).

oh, I didn't refresh the page before posting again 🤦 but the answer to your request is yes, I can do that!

@jessebot
Copy link
Collaborator Author

Looks like they all failed appropriately :)
https://github.com/nextcloud/helm/actions/runs/10063649895/job/27818889110?pr=598#step:8:1

I'll remove the test changes now

@provokateurin
Copy link
Member

Perfect! One more squash please :)

…ing jobs for each test case

Co-authored-by: Kate <[email protected]>
Signed-off-by: jessebot <[email protected]>
@jessebot jessebot force-pushed the add-nginx-testing branch from cc41eb9 to 150a285 Compare July 24, 2024 05:51
@jessebot jessebot requested a review from provokateurin July 24, 2024 05:51
@jessebot
Copy link
Collaborator Author

I have made this all one commit again and made sure to keep your coauthor line in the commit message :) Thanks again for all your help here!

@provokateurin
Copy link
Member

Send it!

@jessebot jessebot merged commit 5709ed0 into nextcloud:main Jul 24, 2024
5 checks passed
@jessebot jessebot deleted the add-nginx-testing branch July 24, 2024 05:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4. to release Ready to be released and/or waiting for tests to finish CI/CD Anything to do with continuous integration or continuous deployment or release automation. hpa horizontal pod autoscaling - triggers a testing workflow nginx container issues related to the nginx container bundling in the nextcloud pod.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants