Skip to content

Commit bded041

Browse files
authored
JavaScript (v3): GitHub - Run unit tests during JavaScript checks. (#6879)
* JavaScript (v3): GitHub - Run unit tests during JavaScript checks. * JavaScript (v3): S3 - Add function comment to copy-object. * JavaScript (v3): GitHub - Add /workflows to sparse checkout. * JavaScript (v3): GitHub - Add format check
1 parent cecbd12 commit bded041

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

.github/workflows/lint-javascript.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ jobs:
1616
sparse-checkout: |
1717
.github
1818
javascriptv3
19+
workflows
1920
- name: Get changed files
2021
id: changed-files
2122
uses: tj-actions/changed-files@v41
@@ -37,3 +38,6 @@ jobs:
3738
run: |
3839
changed_files=(${{steps.changed-files.outputs.all_changed_files}})
3940
./javascriptv3/github_scripts/lint.sh "${changed_files[@]}"
41+
- name: Run unit tests
42+
if: steps.changed-files.outputs.any_changed == 'true'
43+
run: npm test --prefix javascriptv3

javascriptv3/example_code/s3/actions/copy-object.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ import { S3Client, CopyObjectCommand } from "@aws-sdk/client-s3";
88

99
const client = new S3Client({});
1010

11+
/**
12+
* Copy an Amazon S3 object from one bucket to another.
13+
*/
1114
export const main = async () => {
1215
const command = new CopyObjectCommand({
1316
CopySource: "SOURCE_BUCKET/SOURCE_OBJECT_KEY",

javascriptv3/github_scripts/lint.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ done
1212

1313
# Run linting only on filtered files
1414
npm run --prefix javascriptv3 ci-lint -- "${filtered_files[@]//javascriptv3\/}"
15+
16+
# Run format check
17+
npm run --prefix javascriptv3 ci-format-check -- "${@//javascriptv3\/}"

javascriptv3/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@
77
"merge-test-results": "jrm test-results.xml \"**/test_results/**/*.junit.xml\"",
88
"log-tests": "cat test-results.xml",
99
"lint": "lint-staged",
10-
"ci-lint": "eslint"
10+
"ci-lint": "eslint",
11+
"ci-format-check": "prettier --check"
1112
},
1213
"lint-staged": {
1314
"*.{js,ts,jsx,tsx}": [
1415
"eslint",
1516
"prettier -w"
1617
],
17-
"*.{md}": [
18+
"*.md": [
1819
"prettier -w"
1920
]
2021
},

0 commit comments

Comments
 (0)