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
22 changes: 22 additions & 0 deletions .github/workflows/lint_test_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,27 @@ jobs:
run: |
npx @stoplight/spectral-cli lint ./packages/token-introspection/openapi/*.yaml

integration-test:
runs-on: ubuntu-22.04
needs: checkout
timeout-minutes: 5
Comment on lines +105 to +108
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.

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup environment
uses: ./.github/workflows/rafiki/env-setup

- name: Setup hosts
run: |
echo "127.0.0.1 host.docker.internal" | sudo tee -a /etc/hosts
Comment on lines +116 to +118
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.


- name: Build dependencies
run: pnpm --filter integration build:deps

- name: Run tests
run: pnpm --filter integration run-tests

build:
runs-on: ubuntu-22.04
timeout-minutes: 5
Expand All @@ -120,5 +141,6 @@ jobs:
runs-on: ubuntu-22.04
needs:
- build
- integration-test
steps:
- run: echo 'PR Checks Passed'
3 changes: 2 additions & 1 deletion test/integration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.

"test": "jest",
"run-tests": "./scripts/run-tests.sh"
},
Expand Down
Loading