Skip to content

Commit

Permalink
build: make build success if eslint, prettier and 'cdk synth' are all…
Browse files Browse the repository at this point in the history
… passed (#12)

* ci: fail build if eslint or prettier is not applied

* build: run prettier on all supported extensions when pre-commit

* chore: add .prettierignore to ignore term files

* build: build all cdk apps when 'npm run synth:dev'

* style: apply prettier into whole repository

* chore: chmod 644

* ci: disable git core.autocrlf in Windows CI environment

* build: fix format in dependabot.yml

Co-authored-by: Yukitaka Ohmura <[email protected]>
  • Loading branch information
konokenj and ohmurayu authored Jan 25, 2022
1 parent fe8daf9 commit 1e01743
Show file tree
Hide file tree
Showing 12 changed files with 71 additions and 66 deletions.
21 changes: 7 additions & 14 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
{
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json"
},
"plugins": [
"@typescript-eslint"
],
"rules": {
}
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json"
},
"plugins": ["@typescript-eslint"],
"rules": {}
}
20 changes: 9 additions & 11 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
version: 2
updates:

# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
- package-ecosystem: 'github-actions'
directory: '/'
schedule:
interval: "weekly"
interval: 'weekly'

# Maintain dependencies for npm
- package-ecosystem: "npm"
directory: "/"
- package-ecosystem: 'npm'
directory: '/'
schedule:
interval: "weekly"
interval: 'weekly'

# Maintain dependencies for docker
- package-ecosystem: "docker"
directory: "/usecases/guest-webapp-sample/container/sample-ecs-app"
- package-ecosystem: 'docker'
directory: '/usecases/guest-webapp-sample/container/sample-ecs-app'
schedule:
interval: "weekly"

interval: 'weekly'
10 changes: 7 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: build

on:
push:
branches: [ main ]
branches: [main]
pull_request:
branches: [ main ]
branches: [main]

jobs:
build:
Expand All @@ -20,6 +20,9 @@ jobs:
- node: 14
os: windows-latest
steps:
- run: |
git config --global core.autocrlf false
git config --global core.eol lf
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
Expand All @@ -30,7 +33,8 @@ jobs:
echo "node: $(node --version)"
echo "npm: $(npm --version)"
- run: npm ci
- run: npm run lint
- run: npm run lint:ci
- run: npm run format:ci
- run: npm run build --workspaces
- run: npm run test --workspaces
- run: npm run synth:dev --workspaces
61 changes: 31 additions & 30 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,40 @@
default:
before_script:
- npm i -g npm
- echo node $(node --version)
- echo npm $(npm --version)
- npm ci --cache .npm --prefer-offline
cache:
key:
files:
- package-lock.json
prefix: ${CI_PROJECT_NAME}
paths:
- .npm/
before_script:
- npm i -g npm
- echo node $(node --version)
- echo npm $(npm --version)
- npm ci --cache .npm --prefer-offline
cache:
key:
files:
- package-lock.json
prefix: ${CI_PROJECT_NAME}
paths:
- .npm/

variables:
# Disable AWS profile in GitLab Runner to avoid unintended access during `cdk synth`.
# If you use your AWS account to deploy CDK apps, you should remove this, then set secret varibales in GitLab CI/CD settings from web.
AWS_PROFILE: ""
AWS_DEFAULT_REGION: ""
AWS_ACCESS_KEY_ID: ""
AWS_SECRET_ACCESS_KEY: ""
# Disable AWS profile in GitLab Runner to avoid unintended access during `cdk synth`.
# If you use your AWS account to deploy CDK apps, you should remove this, then set secret varibales in GitLab CI/CD settings from web.
AWS_PROFILE: ''
AWS_DEFAULT_REGION: ''
AWS_ACCESS_KEY_ID: ''
AWS_SECRET_ACCESS_KEY: ''

.node-build: &node-build
- npm run lint
- npm run build --workspaces
- npm run test --workspaces
- npm run synth:dev --workspaces
- npm run lint:ci
- npm run format:ci
- npm run build --workspaces
- npm run test --workspaces
- npm run synth:dev --workspaces

build-node14:
stage: build
image: node:14
script:
- *node-build
stage: build
image: node:14
script:
- *node-build

build-node16:
stage: build
image: node:16
script:
- *node-build
stage: build
image: node:16
script:
- *node-build
5 changes: 5 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
LICENSE
CHANGELOG.md
CODE_OF_CONDUCT.md
CONTRIBUTING.md
.github/PULL_REQUEST_TEMPLATE.md
Empty file modified CODE_OF_CONDUCT.md
100755 → 100644
Empty file.
Empty file modified CONTRIBUTING.md
100755 → 100644
Empty file.
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
],
"scripts": {
"lint": "eslint --fix .",
"lint:ci": "eslint .",
"format": "prettier --write .",
"format:ci": "prettier --check .",
"release": "standard-version"
},
"devDependencies": {
Expand All @@ -41,8 +43,10 @@
"*": [
"git-secrets --scan"
],
"*.ts": [
"npx eslint --fix",
"*.(ts|tsx|js|jsx)": [
"npx eslint --fix"
],
"*.(ts|tsx|js|jsx|json|html|yml|yaml|md|graphql|css|scss|less|vue|flow)": [
"npx prettier --write"
]
}
Expand Down
4 changes: 2 additions & 2 deletions tools/cicd/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ module.exports = {
roots: ['<rootDir>/test'],
testMatch: ['**/*.test.ts'],
transform: {
'^.+\\.tsx?$': 'ts-jest'
}
'^.+\\.tsx?$': 'ts-jest',
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# AWS Config Rules based guardrails from AWS Control Tower. Use this conformance
# pack to apply AWS Control Tower detective guardrails to your existing accounts
# prior to enrolling them in AWS Control Tower or to manage resources in your
# accounts in regions not currently supported by AWS Control Tower.
# accounts in regions not currently supported by AWS Control Tower.
###################################################################################

Resources:
Expand Down Expand Up @@ -166,4 +166,4 @@ Resources:
SourceIdentifier: S3_BUCKET_VERSIONING_ENABLED
Scope:
ComplianceResourceTypes:
- AWS::S3::Bucket
- AWS::S3::Bucket
2 changes: 1 addition & 1 deletion usecases/guest-apiapp-sample/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"blea-guest-apiapp-nodejs-sample": "bin/blea-guest-apiapp-nodejs-sample.js"
},
"scripts": {
"synth:dev": "npx cdk synth -c environment=dev",
"synth:dev": "npx cdk synth -c environment=dev && npx cdk synth --app \"npx ts-node bin/blea-guest-apiapp-python-sample.ts\" -c environment=dev",
"depcheck": "npx depcheck --ignore-dirs cdk.out",
"build": "tsc --build",
"clean": "tsc --build --clean && rm -rf cdk.out",
Expand Down
2 changes: 1 addition & 1 deletion usecases/guest-webapp-sample/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"blea-guest-ecsapp-sample": "bin/blea-guest-ecsapp-sample.js"
},
"scripts": {
"synth:dev": "npx cdk synth -c environment=dev",
"synth:dev": "npx cdk synth -c environment=dev && npx cdk synth --app \"npx ts-node bin/blea-guest-asgapp-sample.ts\" -c environment=dev && npx cdk synth --app \"npx ts-node bin/blea-guest-ec2app-sample.ts\" -c environment=dev && npx cdk synth --app \"npx ts-node bin/blea-guest-ecsapp-ssl-sample.ts\" -c environment=dev",
"depcheck": "npx depcheck --ignore-dirs cdk.out",
"build": "tsc --build",
"clean": "tsc --build --clean && rm -rf cdk.out",
Expand Down

0 comments on commit 1e01743

Please sign in to comment.