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

ci: add integration test to lint_test_build #2569

Merged
merged 12 commits into from
Mar 22, 2024

Conversation

BlairCurrey
Copy link
Contributor

@BlairCurrey BlairCurrey commented Mar 19, 2024

Changes proposed in this pull request

  • adds integration tests to ci

Context

fixes #2473

Checklist

  • Related issues linked using fixes #number
  • Tests added/updated
  • Documentation added
  • Make sure that all checks pass
  • Bruno collection updated

no idea what the docker command will do...
@github-actions github-actions bot added the type: ci Changes to the CI label Mar 19, 2024
Copy link

netlify bot commented Mar 19, 2024

Deploy Preview for brilliant-pasca-3e80ec canceled.

Name Link
🔨 Latest commit c34b79d
🔍 Latest deploy log https://app.netlify.com/sites/brilliant-pasca-3e80ec/deploys/65fd8dd43bab6000084eaabd

@@ -4,7 +4,8 @@
"version": "1.0.0",
"description": "",
"scripts": {
"testenv:compose": "docker-compose -f ./testenv/cloud-nine-wallet/docker-compose.yml -f ./testenv/happy-life-bank/docker-compose.yml -f ./testenv/docker-compose.yml",
"build:deps": "pnpm --filter mock-account-service-lib build",
"testenv:compose": "docker compose -f ./testenv/cloud-nine-wallet/docker-compose.yml -f ./testenv/happy-life-bank/docker-compose.yml -f ./testenv/docker-compose.yml",
Copy link
Contributor Author

@BlairCurrey BlairCurrey Mar 19, 2024

Choose a reason for hiding this comment

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

from docker-compose -> docker compose

This is the same for me locally, but in github actions docker-compose is v1 and finds our compose files invalid (because of the top-level name attribute). docker compose is v2.

Comment on lines +105 to +108
integration-test:
runs-on: ubuntu-22.04
needs: checkout
timeout-minutes: 5
Copy link
Contributor Author

@BlairCurrey BlairCurrey Mar 19, 2024

Choose a reason for hiding this comment

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

Originally this was a separate workflow file but I figured I'd include it here since it's the same event trigger.

I considered making this depend on auth, backend, token-introspection but decided not to because I think it gives us a useful signal if integration tests pass and auth/backend do not. This could happen if the failures just dont overlap with the tests cases, or if the backend/auth tests are flakey. Additionally, not making it depend on our longest running jobs ensures that we aren't increasing the time it takes to run CI. The integration tests take ~2 minutes, so they should finish before backend.

Comment on lines +116 to +118
- name: Setup hosts
run: |
echo "127.0.0.1 host.docker.internal" | sudo tee -a /etc/hosts
Copy link
Contributor Author

@BlairCurrey BlairCurrey Mar 19, 2024

Choose a reason for hiding this comment

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

We're eventually going to use hostile to do this in the run-tests script but I think this will end up being permanent for the reason outlined in the end of the body in this issue: #2555

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure I'm following. Why do we need it twice? Because that way, the script itself doesn't prompt?

Copy link
Contributor

Choose a reason for hiding this comment

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

Same question here. In the CI, if "echo "127.0.0.1 host.docker.internal" | sudo tee -a /etc/hosts" command works without prompting, why would it prompt if it was inside the script?

Copy link
Contributor Author

@BlairCurrey BlairCurrey Mar 22, 2024

Choose a reason for hiding this comment

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

Good questions - short answer is that I wonder if hostile will work fine in CI after all, in which case we can get rid of this step. I will test that.

The thinking was hostile will not work in github actions due to sudo prompt (needs confirming). Thus the extra step. Dont ask me about sudo tee I guess I just thought that was special 🙃. And that appending to /etc/hosts and otherwise manually performing a "append if not exist" was better managed by something like hostile, thus not using echo "127.0.0.1 host.docker.internal" | sudo tee -a /etc/hosts. And to answer Max's question, that does actually prompt from the command line - that's what makes me think my original assumptions about github actions and sudo might just be bad.

Also questioning if need hostile at this point. We are already checking for the existence of some line before setting a new one, so we shouldn't be adding duplicates. Beyond that and being cross-platform, which I don't think matters because we're already assuming a unix-like environment (including WSL) with this shell script and elswhere, it basically just does this:

So I'm not really seeing a value-add over checking if a line already exists and if not adding it.

Copy link
Contributor Author

@BlairCurrey BlairCurrey Mar 22, 2024

Choose a reason for hiding this comment

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

I guess I forgot where I was... editing /etc/hosts via hostile in run-tests is not in this branch and adding host step is required regardless here.

I will test using removing this CI step in that branch when this is merged.

@BlairCurrey
Copy link
Contributor Author

BlairCurrey commented Mar 19, 2024

Presumably backend (and auth) gql APIs will soon require a hydra service which is not included in these tests. So the integration tests will fail at that point and we will need to add hydra to the docker environment and handle authentication in the tests.

We should decide which we want to merge first. Either we merge this first and the authentication changes will be blocked until the testenv and tests handle it, or merge the authentication changes and this will be blocked. It seems like we can probably piggy-back off either of these tasks to authenticate with the tests: #2568 #2557

I think being a much larger change, maybe we merge the authentication first (one less thing to implement there). But I don't know how close it is.

@BlairCurrey BlairCurrey marked this pull request as ready for review March 19, 2024 04:00
@BlairCurrey BlairCurrey changed the title ci: WIP new integration test workflow ci: add integration test to lint_test_build Mar 19, 2024
@BlairCurrey
Copy link
Contributor Author

BlairCurrey commented Mar 19, 2024

Presumably backend (and auth) gql APIs will soon require a hydra service which is not included in these tests. So the integration tests will fail at that point and we will need to add hydra to the docker environment and handle authentication in the tests.

We should decide which we want to merge first. Either we merge this first and the authentication changes will be blocked until the testenv and tests handle it, or merge the authentication changes and this will be blocked. It seems like we can probably piggy-back off either of these tasks to authenticate with the tests: #2568 #2557

I think being a much larger change, maybe we merge the authentication first (one less thing to implement there). But I don't know how close it is.

We talked about this in sprint planning and concluded the tests should be runnable w/out spinning up hydra. should work with a NODE_ENV that is test/development and using a special header. So the tests will break with those changes but we can simply update the header in the test requests. Given the changes required are small and authetnication changes dont look imminent I dont think we need to hold of on merging this IMO.

edit: more specifically it looks like we'll just need to add this to the ApolloClient options in test/integration/lib/apolloClient.ts:

    headers: {
      authorization: 'Bearer test_file'
    }

sabineschaller
sabineschaller previously approved these changes Mar 22, 2024
Copy link
Member

@sabineschaller sabineschaller left a comment

Choose a reason for hiding this comment

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

Just one clarifying question but otherwise, LGTM

Comment on lines +116 to +118
- name: Setup hosts
run: |
echo "127.0.0.1 host.docker.internal" | sudo tee -a /etc/hosts
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure I'm following. Why do we need it twice? Because that way, the script itself doesn't prompt?

mkurapov
mkurapov previously approved these changes Mar 22, 2024
Copy link
Contributor

@mkurapov mkurapov left a comment

Choose a reason for hiding this comment

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

Approving for now, just one comment

Comment on lines +116 to +118
- name: Setup hosts
run: |
echo "127.0.0.1 host.docker.internal" | sudo tee -a /etc/hosts
Copy link
Contributor

Choose a reason for hiding this comment

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

Same question here. In the CI, if "echo "127.0.0.1 host.docker.internal" | sudo tee -a /etc/hosts" command works without prompting, why would it prompt if it was inside the script?

@BlairCurrey BlairCurrey dismissed stale reviews from mkurapov and sabineschaller via 5f529b2 March 22, 2024 13:49
@BlairCurrey BlairCurrey merged commit 2c23d2f into main Mar 22, 2024
23 checks passed
@BlairCurrey BlairCurrey deleted the bc/2473/integration-tests-ci branch March 22, 2024 15:18
beniaminmunteanu pushed a commit that referenced this pull request Mar 22, 2024
* ci: WIP new integration test workflow

no idea what the docker command will do...

* fix: deps not found, add debug step

* ci: add debug step

* ci: use docker compose (v2) instead of docker-compose (v1)

* chore: add setup from seed debug logs

* ci: rework jobs into steps

* chore: rm todo comment

* chore: rm debug log

* chore: shorten timeout in integration test

* refactor: move integreation test job to lint_test_build

* chore: test hostile cmd in ci, no setup host step

* Revert "chore: test hostile cmd in ci, no setup host step"

This reverts commit 5f529b2.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: ci Changes to the CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Run tests in CI
3 participants