-
Notifications
You must be signed in to change notification settings - Fork 189
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
Use Turborepo for tests and add turbo cache for CI eslint and unit-tests #3458
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome.
Should we do a follow-up to run a turbo-repo cache server on staging for local devs to leverage too? Or is this not needed locally?
.github/workflows/eslint-ci.yml
Outdated
uses: felixmosh/turborepo-gh-artifacts@v1 | ||
with: | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
server-token: ${{ secrets.TURBO_SERVER_TOKEN }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this token supposed to look like? I'm reading the docs and I don't totally understand the point of it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The answer is: it's an opaque secret token (can be anything), see felixmosh/turborepo-gh-artifacts#1 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added TURBO_SERVER_TOKEN
to the repo.
I don't think it's needed for local dev since Turborepo keeps a local cache in a Also there is a new feature in version 1.2 to add signature verification: |
.github/workflows/eslint-ci.yml
Outdated
- name: Install dependencies and run eslint | ||
run: | | ||
pnpm install | ||
pnpm lint | ||
pnpm turbo run lint --api="http://127.0.0.1:9080" --token="${{ secrets.TURBO_SERVER_TOKEN }}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can't access secrets.*
directly in a called workflow. You have to pass the secret into the workflow. Checkout how I do it with the Docker username and password:
- define the secret to be passed in https://github.com/Seneca-CDOT/telescope/blob/master/.github/workflows/docker-build-and-push.yml#L60-L63
- pass it in https://github.com/Seneca-CDOT/telescope/blob/master/.github/workflows/continuous-delivery.yml#L14-L16
Do this for both of the workflow changes you're making.
We're not uploading them to a cache, right? I'm not sure we need this. |
Right, it would only be useful if we used an actual server. |
.github/workflows/unit-tests-ci.yml
Outdated
@@ -2,6 +2,13 @@ name: Unit Tests Workflow | |||
|
|||
on: | |||
workflow_call: | |||
secrets: | |||
github-token: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, bump these in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just did. I don't understand why CI fails to start, I followed your docker example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Invalid workflow file: .github/workflows/continuous-integration.yml#L22
The workflow is not valid. .github/workflows/continuous-integration.yml (Line: 22, Col: 21): Invalid secret, github-token is not defined in the referenced workflow. .github/workflows/continuous-integration.yml (Line: 23, Col: 24): Invalid secret, turborepo-token is not defined in the referenced workflow.
From https://github.com/Seneca-CDOT/telescope/actions/runs/2150363645
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks right to me. NOTE: we don't run linked workflows from PRs, only what's on master
, so we have to land this to see it happen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's uphappy with the GITHUB_TOKEN
stuff
@@ -18,10 +18,16 @@ jobs: | |||
# Make sure eslint passes | |||
eslint: | |||
uses: Seneca-CDOT/telescope/.github/workflows/eslint-ci.yml@master | |||
secrets: | |||
github-token: ${{ secrets.GITHUB_TOKEN }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can't pass this in (it's a synthesized token, not a real one), see https://github.community/t/how-to-pass-github-token-to-reusable-workflows/204905/6. What if you use {{ github.token }}
below instead and get rid of this.
Issue This PR Addresses
Fixes #3351
Type of Change
Description
This PR changes
pnpm test
to use Turborepo and adds support for Turborepo's cache in CI eslint and unit-tests.The downside of this is not seeing all the green check marks when running tests locally, so I have left the option to run tests without Turborepo by running
pnpm jest
.For CI I am using a GitHub Action that builds a local server (on port 9080) where Turborepo goes to look for the cache. To make it work, a
TURBO_SERVER_TOKEN
needs to be added to the repo.If this is successful, we will be able to do the same for our e2e tests.
Resources:
Custom Remote Cache
TurboRepo with github artifacts
Steps to test the PR
pnpm test
Checklist