Skip to content

Commit 1c5a4d0

Browse files
adadoucheAbdelhalim Dadouche
andauthored
Adding Jest test and pipeline output location change (#83)
* adding new folders to exclude * updating the architecture diagrams * adding / moving helper scripts * moving the base image assests to source-repo * adjusting buildspec file with new nfs mount location & adding debug logs * refactoring poky/poky-ami project & esling formatting * eslint & jest config refactoring / updates * library version updates & scripts commands ajdustments * github workflow adjustment to conform with new script location * deprecating existing/former cdk libraries and test * updating package-lock.json * adding new refactored version of the CDK construct with less dependecies between each other: - improve the overall deployment time - reduce the number of EFS instance requried (1 from 3 per pipeline) - provide reuable resourcess across pipelines (s3 buckets, kms keys, ecr reigistry, etc) - remove oprhan code * updated readme * updated tests snapshot * eslint reformatting * forcing dependency to prevent iam role issue on first run of pipeline * managin eof / eol with lf only (as I'm working o windows and this can cause issues if env is not configured properly) * updated test due to dependency change * moving build assets script out to avoid deployment in dist * updating reference to build assets script * adding execute permission * package.json: - updated dependencies/devDependencies/peerDependencies - added license attribute - switching to yarn README.md: - doc adjustement due toyarn switch - confirmed steps for linking Yarn switch for the following reasons: - provides better linking / dependencies management - faster than npm (somehow) - enable easier linking when developping * downsizing codebuild ComputeType to save on cost and because resources are not fully used * Normalize all the line endings * forcing lf endings * adding docker image file to allow uplaod & zip of source repo via cdk assets * variable renaming to improve readability * differentiating ProjectKind from deprecated API * - code refactoring to remove local archive creation (using assets and bucket deployement instead - variable renaming to improve readability * minor comment changes * moving the vmimport bucket class to the deprecated folder * adjusting the vmimport bucket class import * removing references to VMImportBucket * simplifying the build asset script * excluding the test folder from the dist/build output * adding excluded folder fom build and eslint * cleanup and relocation of scripts and assets * variable renaming to improve readability * - variable renaming to improve readability - removed use of custom S3 Bucket object for VM Import (enabled by design if needed) - updating nag snapshots * updating script path * varible renaming to improve readability * switching to S3 poll trigger * code cleanup * adjusting the readme with additional details * function refactoring * improving the doc / readme * minor change in navigation * adding the ability to use a custom local source path be used to create a pipeline * switching to codepipeline_actions.S3Trigger.EVENTS, * - switching to codepipeline_actions.S3Trigger.EVENTS, - adding a custom project type where you can provide the location of your buildspec * variable renaming * - extending create ami script with additional parameters - adding tags and name to the created ami * test updates * removing node 18/20 support * removing deprecated code * switching to yarn * switching to yarn * fixing shell check * fixing shell check warnings * adjusting shell check script path * pre-commit failures fixes * pre-commit failures fixes * adding a post install script to force dist folder generation on install * reveerting change * adjusting lifecycle scripts * updating to Yarn 2 (v4.6.0) * updating to Yarn 2 (v4.6.0) * adding package-lock for npm compatibility * fixing renesas script * doc issue * adjusting packge.json with files to include * adjusting packge.json with files to include * refactoring build process * refactoring build process * refactoring build process * refactoring build process * adding vscode settings * revisiting eslint / jest config to accomodate build change * addressing typedoc issue with incomplete link * removing unused code * minor update due to package.json change * adding exclusing in the npmignore * adding exclusing in the npmignore * fixing type for environment variables in code pipelines * adding jest test and fixing output location for pipelines * adding jest test and fixing output location for pipelines * Update doc.yml update to support yarn * Major update to 0.2.0 (#76) * adding new folders to exclude * updating the architecture diagrams * adding / moving helper scripts * moving the base image assests to source-repo * adjusting buildspec file with new nfs mount location & adding debug logs * refactoring poky/poky-ami project & esling formatting * eslint & jest config refactoring / updates * library version updates & scripts commands ajdustments * github workflow adjustment to conform with new script location * deprecating existing/former cdk libraries and test * updating package-lock.json * adding new refactored version of the CDK construct with less dependecies between each other: - improve the overall deployment time - reduce the number of EFS instance requried (1 from 3 per pipeline) - provide reuable resourcess across pipelines (s3 buckets, kms keys, ecr reigistry, etc) - remove oprhan code * updated readme * updated tests snapshot * eslint reformatting * forcing dependency to prevent iam role issue on first run of pipeline * managin eof / eol with lf only (as I'm working o windows and this can cause issues if env is not configured properly) * updated test due to dependency change * moving build assets script out to avoid deployment in dist * updating reference to build assets script * adding execute permission * package.json: - updated dependencies/devDependencies/peerDependencies - added license attribute - switching to yarn README.md: - doc adjustement due toyarn switch - confirmed steps for linking Yarn switch for the following reasons: - provides better linking / dependencies management - faster than npm (somehow) - enable easier linking when developping * downsizing codebuild ComputeType to save on cost and because resources are not fully used * Normalize all the line endings * forcing lf endings * adding docker image file to allow uplaod & zip of source repo via cdk assets * variable renaming to improve readability * differentiating ProjectKind from deprecated API * - code refactoring to remove local archive creation (using assets and bucket deployement instead - variable renaming to improve readability * minor comment changes * moving the vmimport bucket class to the deprecated folder * adjusting the vmimport bucket class import * removing references to VMImportBucket * simplifying the build asset script * excluding the test folder from the dist/build output * adding excluded folder fom build and eslint * cleanup and relocation of scripts and assets * variable renaming to improve readability * - variable renaming to improve readability - removed use of custom S3 Bucket object for VM Import (enabled by design if needed) - updating nag snapshots * updating script path * varible renaming to improve readability * switching to S3 poll trigger * code cleanup * adjusting the readme with additional details * function refactoring * improving the doc / readme * minor change in navigation * adding the ability to use a custom local source path be used to create a pipeline * switching to codepipeline_actions.S3Trigger.EVENTS, * - switching to codepipeline_actions.S3Trigger.EVENTS, - adding a custom project type where you can provide the location of your buildspec * variable renaming * - extending create ami script with additional parameters - adding tags and name to the created ami * test updates * removing node 18/20 support * removing deprecated code * switching to yarn * switching to yarn * fixing shell check * fixing shell check warnings * adjusting shell check script path * pre-commit failures fixes * pre-commit failures fixes * adding a post install script to force dist folder generation on install * reveerting change * adjusting lifecycle scripts * updating to Yarn 2 (v4.6.0) * updating to Yarn 2 (v4.6.0) * adding package-lock for npm compatibility * fixing renesas script * Update doc.yml update to support yarn * fixing formatting --------- Co-authored-by: Abdelhalim Dadouche <[email protected]> * Major update to 0.2.0 (#76) * adding new folders to exclude * updating the architecture diagrams * adding / moving helper scripts * moving the base image assests to source-repo * adjusting buildspec file with new nfs mount location & adding debug logs * refactoring poky/poky-ami project & esling formatting * eslint & jest config refactoring / updates * library version updates & scripts commands ajdustments * github workflow adjustment to conform with new script location * deprecating existing/former cdk libraries and test * updating package-lock.json * adding new refactored version of the CDK construct with less dependecies between each other: - improve the overall deployment time - reduce the number of EFS instance requried (1 from 3 per pipeline) - provide reuable resourcess across pipelines (s3 buckets, kms keys, ecr reigistry, etc) - remove oprhan code * updated readme * updated tests snapshot * eslint reformatting * forcing dependency to prevent iam role issue on first run of pipeline * managin eof / eol with lf only (as I'm working o windows and this can cause issues if env is not configured properly) * updated test due to dependency change * moving build assets script out to avoid deployment in dist * updating reference to build assets script * adding execute permission * package.json: - updated dependencies/devDependencies/peerDependencies - added license attribute - switching to yarn README.md: - doc adjustement due toyarn switch - confirmed steps for linking Yarn switch for the following reasons: - provides better linking / dependencies management - faster than npm (somehow) - enable easier linking when developping * downsizing codebuild ComputeType to save on cost and because resources are not fully used * Normalize all the line endings * forcing lf endings * adding docker image file to allow uplaod & zip of source repo via cdk assets * variable renaming to improve readability * differentiating ProjectKind from deprecated API * - code refactoring to remove local archive creation (using assets and bucket deployement instead - variable renaming to improve readability * minor comment changes * moving the vmimport bucket class to the deprecated folder * adjusting the vmimport bucket class import * removing references to VMImportBucket * simplifying the build asset script * excluding the test folder from the dist/build output * adding excluded folder fom build and eslint * cleanup and relocation of scripts and assets * variable renaming to improve readability * - variable renaming to improve readability - removed use of custom S3 Bucket object for VM Import (enabled by design if needed) - updating nag snapshots * updating script path * varible renaming to improve readability * switching to S3 poll trigger * code cleanup * adjusting the readme with additional details * function refactoring * improving the doc / readme * minor change in navigation * adding the ability to use a custom local source path be used to create a pipeline * switching to codepipeline_actions.S3Trigger.EVENTS, * - switching to codepipeline_actions.S3Trigger.EVENTS, - adding a custom project type where you can provide the location of your buildspec * variable renaming * - extending create ami script with additional parameters - adding tags and name to the created ami * test updates * removing node 18/20 support * removing deprecated code * switching to yarn * switching to yarn * fixing shell check * fixing shell check warnings * adjusting shell check script path * pre-commit failures fixes * pre-commit failures fixes * adding a post install script to force dist folder generation on install * reveerting change * adjusting lifecycle scripts * updating to Yarn 2 (v4.6.0) * updating to Yarn 2 (v4.6.0) * adding package-lock for npm compatibility * fixing renesas script * Update doc.yml update to support yarn * fixing formatting --------- Co-authored-by: Abdelhalim Dadouche <[email protected]> * updating snapshot * updating snapshot and test * changing target to es2020 instead of ES2020 * replacing reaplce all with global regexp * updating yarn and package lock files --------- Co-authored-by: Abdelhalim Dadouche <[email protected]>
1 parent 988e320 commit 1c5a4d0

28 files changed

+3684
-1109
lines changed

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@ root = true
77
[*]
88
end_of_line = lf
99
insert_final_newline = true
10+
charset = utf-8
11+
indent_style = space
12+
tab_width = 2

.gitignore

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,40 @@
22
!jest.config.js
33
!.eslintrc.js
44
!.prettierrc.js
5+
6+
!lib/**/*.ts
7+
!test/**/*.ts
58
*.d.ts
6-
node_modules
9+
710
dist
11+
node_modules
12+
13+
# yarn asset
14+
yarn-install.log
15+
.yarn/*
16+
!.yarn/releases/
17+
!.yarn/plugins/
18+
!.yarn/versions/
19+
!.yarn/sdks/
20+
.pnp.*
21+
22+
# yarn asset
23+
yarn-install.log
24+
.yarn/*
25+
!.yarn/releases/
26+
!.yarn/plugins/
27+
!.yarn/versions/
28+
!.yarn/sdks/
29+
.pnp.*
30+
31+
# yarn asset
32+
yarn-install.log
33+
.yarn/*
34+
!.yarn/releases/
35+
!.yarn/plugins/
36+
!.yarn/versions/
37+
!.yarn/sdks/
38+
.pnp.*
839

940
# yarn asset
1041
yarn-install.log
@@ -28,3 +59,4 @@ cdk.context.json
2859

2960
assets
3061
source-zip
62+
aws4embeddedlinux-cdk-lib-*.tgz

.npmignore

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
1-
*.ts
2-
!*.d.ts
1+
.yarn
2+
.github
3+
.vscode
4+
test
35

4-
# CDK asset staging directory
5-
.cdk.staging
6-
cdk.out
6+
.editorconfig
7+
.gitattributes
8+
.pre-commit-config.yaml
9+
eslint.config.mjs
10+
jest.config.js
11+
typedoc.json
12+
tsconfig.*.json
13+
package-lock.json
14+
yarn.lock
15+
16+
CODE_OF_CONDUCT.md
17+
CONTRIBUTING.md
18+
SECURITY.md

.vscode/settings.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"eslint.alwaysShowStatus": true,
3+
"editor.codeActionsOnSave": {
4+
"source.fixAll.eslint": true
5+
},
6+
"explorer.autoReveal": false
7+
}

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ npm install aws4embeddedlinux/aws4embeddedlinux-ci
213213
of `yarn':
214214

215215
```bash
216-
yarn add github:aws4embeddedlinux/aws4embeddedlinux-ci
216+
yarn add aws4embeddedlinux-cdk-lib@aws4embeddedlinux/aws4embeddedlinux-ci
217217
yarn install
218218
```
219219

@@ -254,7 +254,7 @@ const projectPipeline = new EmbeddedLinuxCodePipelineStack(app, "demo-project",
254254
});
255255
```
256256

257-
Refer to the [API Documentation](https://aws4embeddedlinux.github.io/aws4embeddedlinux-ci) and the [sample](github.com/aws4embeddedlinux/aws4embeddedlinux-ci-examples) for more details.
257+
Refer to the [API Documentation](https://aws4embeddedlinux.github.io/aws4embeddedlinux-ci) and the [sample](https://github.com/aws4embeddedlinux/aws4embeddedlinux-ci-examples) for more details.
258258

259259
Once you have completed the code of your application, you can deploy the CDK stack using:
260260

@@ -275,7 +275,7 @@ This will create an Ubuntu based container for building the Yocto images.
275275
276276
> [!NOTE]
277277
>
278-
> We recommend you to deploy first the 'Base Image' pipeline and once the pipeline completes successfully, then you can deploy the other pipelines in you application as described in the [sample](github.com/aws4embeddedlinux/aws4embeddedlinux-ci-examples).
278+
> We recommend you to deploy first the 'Base Image' pipeline and once the pipeline completes successfully, then you can deploy the other pipelines in you application as described in the [sample](https://github.com/aws4embeddedlinux/aws4embeddedlinux-ci-examples).
279279
>
280280
281281
Once your pipelines completes successfully, the Yocto deploy directory generated content will be pushed into a S3 bucket.

eslint.config.mjs

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import typescriptEslintEslintPlugin from "@typescript-eslint/eslint-plugin";
2+
import simpleImportSort from "eslint-plugin-simple-import-sort";
23
import tsdoc from "eslint-plugin-tsdoc";
34
import globals from "globals";
45
import tsParser from "@typescript-eslint/parser";
56
import path from "node:path";
67
import { fileURLToPath } from "node:url";
7-
import eslint from "@eslint/js";
8-
import tseslint from "typescript-eslint";
8+
import eslintjs from "@eslint/js";
9+
import eslintts from "typescript-eslint";
910
import { FlatCompat } from "@eslint/eslintrc";
1011

1112
const __filename = fileURLToPath(import.meta.url);
@@ -16,14 +17,22 @@ const gitignorePath = path.resolve(__dirname, ".gitignore");
1617

1718
const compat = new FlatCompat({
1819
baseDirectory: __dirname,
19-
recommendedConfig: eslint.configs.recommended,
20-
allConfig: eslint.configs.all,
20+
recommendedConfig: eslintjs.configs.recommended,
21+
allConfig: eslintjs.configs.all,
2122
});
2223

2324
export default [
25+
...compat.extends(
26+
"eslint:recommended",
27+
"plugin:@typescript-eslint/recommended",
28+
"plugin:prettier/recommended",
29+
),
30+
...eslintts.configs.recommended,
2431
{
32+
...eslintjs.configs.recommended,
2533
plugins: {
2634
"@typescript-eslint": typescriptEslintEslintPlugin,
35+
"simple-import-sort": simpleImportSort,
2736
tsdoc,
2837
},
2938

@@ -39,7 +48,7 @@ export default [
3948

4049
parserOptions: {
4150
sourceType: "module",
42-
project: "./tsconfig.json",
51+
project: "./tsconfig.eslint.json",
4352
},
4453
},
4554

@@ -61,8 +70,21 @@ export default [
6170
"prettier/prettier": [
6271
"error",
6372
{
64-
singleQuote: true,
65-
trailingComma: "es5",
73+
singleQuote: false,
74+
trailingComma: "all",
75+
},
76+
],
77+
78+
"@typescript-eslint/no-unused-vars": [
79+
"error",
80+
{
81+
args: "all",
82+
argsIgnorePattern: "^_",
83+
caughtErrors: "all",
84+
caughtErrorsIgnorePattern: "^_",
85+
destructuredArrayIgnorePattern: "^_",
86+
varsIgnorePattern: "^_",
87+
ignoreRestSiblings: true,
6688
},
6789
],
6890
},
@@ -77,13 +99,6 @@ export default [
7799
"/test/**",
78100
"/tmp/**",
79101
],
80-
...eslint.configs.recommended,
81102
},
82103
includeIgnoreFile(gitignorePath),
83-
...compat.extends(
84-
"eslint:recommended",
85-
"plugin:@typescript-eslint/recommended",
86-
"plugin:prettier/recommended",
87-
),
88-
...tseslint.configs.recommended,
89104
];

jest.config.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,4 @@
11
/* eslint-env node */
2-
// module.exports = {
3-
// testEnvironment: "node",
4-
// roots: ["<rootDir>/test"],
5-
// testMatch: ["**/*.test.ts"],
6-
// transform: {
7-
// "^.+\\.tsx?$": "ts-jest",
8-
// },
9-
// };
10-
112
export const testEnvironment = "node";
123
export const roots = ["<rootDir>/test"];
134
export const testMatch = ["**/*.test.ts"];

lib/codepipeline-embedded-linux.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export interface EmbeddedLinuxCodePipelineProps extends cdk.StackProps {
4949
readonly buildPolicyAdditions?: iam.PolicyStatement[];
5050
/** Additional build environment variables to the build project. */
5151
readonly environmentVariables?: {
52-
string: codebuild.BuildEnvironmentVariable;
52+
[key: string]: codebuild.BuildEnvironmentVariable;
5353
};
5454
/** The encryption key use across*/
5555
readonly encryptionKey: kms.Key;
@@ -272,12 +272,12 @@ export class EmbeddedLinuxCodePipelineStack extends cdk.Stack {
272272
project,
273273
});
274274

275-
const artifactAction: codepipeline_actions.S3DeployAction =
275+
const outputAction: codepipeline_actions.S3DeployAction =
276276
new codepipeline_actions.S3DeployAction({
277-
actionName: "Artifact",
277+
actionName: "Output",
278278
input: buildActionOutputArtifact,
279-
bucket: props.pipelineArtifactBucket,
280-
objectKey: `${props.pipelineArtifactPrefix}/${sourceRepoAsset.s3ObjectKey}`,
279+
bucket: props.pipelineOutputBucket,
280+
objectKey: `${props.pipelineOutputPrefix}`,
281281
});
282282

283283
/** Here we create the logic to check for presence of ECR image on the CodeCodePipeline automatic triggering upon resource creation,
@@ -352,8 +352,8 @@ export class EmbeddedLinuxCodePipelineStack extends cdk.Stack {
352352
actions: [buildAction],
353353
},
354354
{
355-
stageName: "Artifact",
356-
actions: [artifactAction],
355+
stageName: "Output",
356+
actions: [outputAction],
357357
},
358358
],
359359
},

lib/index.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,8 @@
1-
import * as s3 from "aws-cdk-lib/aws-s3";
2-
31
export * from "./codebuild-embedded-linux";
42
export * from "./codepipeline-embedded-linux-base-image";
53
export * from "./codepipeline-embedded-linux";
64
export * from "./codepipeline-resources";
75

8-
export function isBucketVersioned(bucket: s3.Bucket | s3.IBucket) {
9-
const bucketCfn: s3.CfnBucket = bucket.node.defaultChild as s3.CfnBucket;
10-
if (
11-
bucketCfn.versioningConfiguration &&
12-
(
13-
bucketCfn.versioningConfiguration as s3.CfnBucket.VersioningConfigurationProperty
14-
).status != "Enabled"
15-
) {
16-
return true;
17-
}
18-
return false;
19-
}
20-
216
/**
227
* The type of project built.
238
*/

package-lock.json

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)