-
Notifications
You must be signed in to change notification settings - Fork 51
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
@W-11831625@: Ported testing jobs from CircleCI to Github Actions. #843
Conversation
@@ -0,0 +1,205 @@ | |||
name: run-tests |
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 runs all the tests, and it has parameters to let us make matrices for node versions. So we could easily create a daily smoke test job that invokes this one the same way the validate_pr one does.
@@ -74,6 +74,7 @@ | |||
"@types/tmp": "^0.2.3", | |||
"@types/uuid": "^8.3.4", | |||
"chai": "^4", | |||
"cross-env": "^7.0.3", |
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.
@@ -135,6 +136,7 @@ | |||
"postpack": "rm -f oclif.manifest.json", | |||
"lint": "eslint ./src --ext .ts", | |||
"test": "./gradlew test jacocoTestCoverageVerification && nyc mocha --timeout 10000 --retries 5 \"./test/**/*.test.ts\"", | |||
"test-quiet": "cross-env SFGE_LOGGING=false ./gradlew test jacocoTestCoverageVerification && nyc mocha --timeout 10000 --retries 5 \"./test/**/*.test.ts\"", |
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.
Using the new variable, we can disable SFGE's internal logging, which is important to avoid overflowing the logs in Github Action.
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 can see why this is important. Though when we have failures, the logs would surely help with troubleshooting.
How about writing the output to a file instead of letting it overflow to the console window?
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.
My assumption is that, for a test failure, you'd check the artifact to see what the failures were, and then run those specific tests locally to reproduce.
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 suppose my discomfort comes from situations where the issue doesn't repro locally. Can we set a higher threshold for logging rather than completely turning it off?
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'll see how doable that is and get back to you.
# Upload the test results and coverage information as artifacts. | ||
- name: Upload node test artifacts | ||
if: ${{ always() }} | ||
uses: actions/upload-artifact@v3 |
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.
Test results get saved as artifacts, so we can view the specifics of the run by downloading and unzipping those.
name: unit-test-dist | ||
path: ./dist | ||
# Run the unit tests. Use the -quiet variant so SFGE logs don't blow up the console. | ||
- name: Run Tests |
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.
If the tests fail, these jobs exit with a non-zero code, indicating a failure.
.github/workflows/validate-pr.yml
Outdated
name: validate-pr | ||
on: | ||
pull_request: | ||
types: [edited, opened, reopened, synchronized] |
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.
Runs on basically any PR action.
// Show log4j output during tests | ||
showStandardStreams = true | ||
// Show log4j output during tests, unless env-var to disable them is set. | ||
showStandardStreams = (System.getenv("SFGE_LOGGING") != "false") |
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 the part where the new env-var is used.
const results = (await RuleResultRecombinator.recombineAndReformatResults(retireJsVerboseViolations, OUTPUT_FORMAT.HTML, new Set(['retire-js']), true)).results as string; | ||
const violationString = results.split("const violations = [")[1].split("];\n")[0]; | ||
const violationString = results.split("const violations = [")[1].split("];")[0]; |
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 was failing in Windows, on Powershell. I believe the problem was that because Windows uses \r\n
instead of \n
, the split was failing.
@@ -7,7 +7,7 @@ import { ENGINE, LANGUAGE } from '../../../src/Constants'; | |||
import { Rule, RuleGroup } from '../../../src/types'; | |||
import LocalCatalog from '../../../src/lib/services/LocalCatalog'; | |||
import { expect } from 'chai'; | |||
import {Controller} from '../../../lib/Controller'; | |||
import {Controller} from '../../../src/Controller'; |
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 import path was wrong.
ce82b39
to
a03837d
Compare
@@ -0,0 +1,203 @@ | |||
name: run-tests | |||
on: | |||
workflow_call: |
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.
workflow_call
lets us reuse this across all of the places where we might want to run tests, which is pretty helpful.
|
||
jobs: | ||
# Step 1: Verify that the tag we're trying to release is a valid candidate for publishing. | ||
verify-candidate-tag: |
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 pretty closely copied from validate-candidate-branch.sh
, just split into a job and converted to use tags.
PACKAGE_VERSION=v`cat package.json | jq '.version' | xargs` | ||
[[ ${TAG} == ${PACKAGE_VERSION} ]] || (echo "Tag name must match package.json version, prefixed by lowercase v" && exit 1) | ||
# Step 2: Publish the tag as a release candidate. | ||
publish-rc: |
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 job is analogous to an example job provided by the CLI team, with the only significant difference being that we use the latest-rc
tag, whereas they use latest
.
.github/workflows/run-tests.yml
Outdated
- uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'temurin' | ||
java-version: '11' # For now, Java version is hardcoded. It could be changed to a matrix in the future. |
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.
Shouldn't this be 8
?
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'm pretty sure this should be 11. But we could matrixify it so it uses 8 and 11.
.github/workflows/run-tests.yml
Outdated
needs: build-dependencies | ||
steps: | ||
# Check out the code. | ||
- uses: actions/checkout@v2 |
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.
Reading around, I see there's a actions/checkout@v3
as well. Is a specific reason to use v2 instead of v3?
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.
Noticed a combination of v3 in the release workflow and v2 in the test workflow.
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.
No. I'll switch to v3 throughout.
.github/workflows/run-tests.yml
Outdated
- uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'temurin' | ||
java-version: '11' # For now, Java version is hardcoded. It could be changed to a matrix in the future. |
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 as above - should this be 8
?
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.
See above.
# If the path starts with C:, we need to rip that off (needed for Windows). | ||
ADJUSTED_TARBALL_PATH=`[[ $RAW_TARBALL_PATH = C* ]] && echo $RAW_TARBALL_PATH | cut -d':' -f 2 || echo $RAW_TARBALL_PATH` | ||
# Pipe in a `y` to simulate agreeing to install an unsigned package. Use a URI of the file's full path. | ||
echo y | sfdx plugins:install "file://${ADJUSTED_TARBALL_PATH}/${TARBALL_NAME}" |
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.
Can windows fail with the /
in the path instead of \
?
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.
In general, for this block, how about gating with an "if os == windows" check?
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 never saw it fail, so I think it should be fine without.
- uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'temurin' | ||
java-version: '11' # For now, Java version is hardcoded. |
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.
Should this be 8
?
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.
Probably. Good catch.
Edit: Actually, no I think it should be 11. Because this is the RC test, not the building for publishing. We want to test with v11, right?
(Alternatively, we could matrixify this and test with both 8 and 11. Thoughts?)
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.
Ah, I see why 11 then. Agree that this doesn't have to be 8. I like the idea of testing with multiple java versions. Especially to keep up with the later versions. Would it be easy to include now while we are here?
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.
Shouldn't be too hard.
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.
So many details covered, this looks great! I had a few minor questions.
027e323
to
0ca8253
Compare
@@ -13,7 +13,7 @@ | |||
}, | |||
"dependencies": { | |||
"@actions/core": "^1.2.4", | |||
"@actions/github": "^4.0.0" | |||
"@actions/github": "^5.0.0" |
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.
Incrementation was necessary to bypass this issue: octokit/plugin-rest-endpoint-methods.js#172
const title = pullRequest.title; | ||
const baseBranch = pullRequest.base.ref; | ||
if (verifyPRTitleForBugId(title) && verifyPRTitleForBadTitle(title) && verifyPRTitleForBaseBranch(title, baseBranch)) { | ||
const title = pullRequest.title as string; |
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.
Linting fixes.
@@ -31,14 +30,6 @@ describe("Positive Tests", () => { | |||
it("Title does not start with invalid tokens d/W or r/W", () => { | |||
expect(verifyPRTitleForBadTitle("@W-12345678")).to.equal(true); | |||
}); | |||
|
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.
Removed unneeded tests.
No description provided.