From a835a5802a38844a93d7336002b03f8002ca4ecc Mon Sep 17 00:00:00 2001 From: Johanna Ahlskog Date: Thu, 14 Sep 2023 10:01:26 +0200 Subject: [PATCH] Changes in Compliance controls structure --- .eslintrc.json | 31 +++++++++++++++++++ .gitattributes | 1 - .github/workflows/pipeline.yml | 39 +++++------------------- .gitignore | 2 ++ .prettierignore | 3 +- CODEOWNERS | 4 --- LICENSE | 22 ------------- LinitingAndFormat.md | 26 ++++++++++++++++ README.md | 4 +-- __tests__/index.test.ts | 7 ----- action.yml | 8 +---- package-lock.json | 8 ++--- package.json | 29 +++++------------- src/test/compliance-state-action.test.ts | 0 tsconfig.json | 34 +-------------------- 15 files changed, 84 insertions(+), 134 deletions(-) create mode 100644 .eslintrc.json delete mode 100644 .gitattributes delete mode 100644 CODEOWNERS delete mode 100644 LICENSE create mode 100644 LinitingAndFormat.md delete mode 100644 __tests__/index.test.ts create mode 100644 src/test/compliance-state-action.test.ts diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 00000000..acbbf12a --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,31 @@ +{ + "root": true, + "parser": "@typescript-eslint/parser", + "plugins": ["@typescript-eslint"], + "extends": [ + "eslint:recommended", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended" + ], + "ignorePatterns": ["node_modules", "test"], + "rules": { + "@typescript-eslint/explicit-function-return-type": "warn", + "@typescript-eslint/typedef": [ + "error", + { + "arrayDestructuring": true, + "arrowCallSignature": true, + "arrowParameter": true, + "callSignature": true, + "memberVariableDeclaration": true, + "parameter": true, + "propertyDeclaration": true, + "objectDestructuring": true, + "variableDeclaration": true, + "variableDeclarationIgnoreFunction": true + } + ], + "@typescript-eslint/no-inferrable-types": 0, + "@typescript-eslint/naming-convention": ["error", { "selector": "variableLike", "format": ["camelCase"] }] + } + } \ No newline at end of file diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 2e2c7b23..00000000 --- a/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -dist/** -diff linguist-generated=true \ No newline at end of file diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index f7a23286..0e111f4f 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -1,48 +1,23 @@ name: Build run-name: ${{ github.actor }} is testing out github actions -# permissions: - # actions: read - # checks: read - # contents: read - # deployments: read - # id-token: write - # issues: read - # discussions: read - # packages: read - # pages: read - # pull-requests: read - # repository-projects: read - # security-events: read - # statuses: read +permissions: + contents: write + pages: write + id-token: write on: [push] jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Run a one-line script - run: echo Hello, world! - - name: Run a multi-line script - run: | - echo Add other actions to build, - echo test, and deploy your projectss - name: Setup node uses: actions/setup-node@v3 - name: Install run: npm ci - name: Build - run: npm run package - # - name: 'Az CLI login' - # uses: azure/login@v1 - # with: - # client-id: ${{ secrets.AZURE_CLIENT_ID }} - # tenant-id: ${{ secrets.AZURE_TENANT_ID }} - # subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} - # - name: 'Run Azure CLI commands' - # run: az account show - - name: 'Custom Task running' + run: npm run build + - name: 'Run Compliance State' uses: ./ with: - repo-token: ${{ secrets.MY_GITHUB_PAT}} + subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 47fb5033..4787cd01 100644 --- a/.gitignore +++ b/.gitignore @@ -101,3 +101,5 @@ __tests__/runner/* .idea .vscode *.code-workspace + +dist \ No newline at end of file diff --git a/.prettierignore b/.prettierignore index 64f046d1..edcb51e5 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,3 +1,4 @@ dist/ node_modules/ -coverage/ \ No newline at end of file +coverage/ +README.md \ No newline at end of file diff --git a/CODEOWNERS b/CODEOWNERS deleted file mode 100644 index 6ac23c1d..00000000 --- a/CODEOWNERS +++ /dev/null @@ -1,4 +0,0 @@ -# Repository CODEOWNERS - -* @actions/actions-runtime -* @ncalteen \ No newline at end of file diff --git a/LICENSE b/LICENSE deleted file mode 100644 index a426ef25..00000000 --- a/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ - -The MIT License (MIT) - -Copyright (c) 2018 GitHub, Inc. and contributors - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. \ No newline at end of file diff --git a/LinitingAndFormat.md b/LinitingAndFormat.md new file mode 100644 index 00000000..240e729d --- /dev/null +++ b/LinitingAndFormat.md @@ -0,0 +1,26 @@ +# How to install linting and format + +1. Run the following commands (be in the root, if you don't have a package.json there, run npm init first to create one): + +```yaml +npm install eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin husky prettier --save-dev +npm pkg set scripts.prepare="husky install" +npm run prepare +``` + +2. Copy files: .eslintrc.json, .prettierignore, .prettierrc and .husky/pre-commit + +3. Add following to script section in package.json: + +```json +"lint": "eslint . --ext .ts", +"lint:fix": "eslint . --fix --ext .ts", +"format:write": "npx prettier -w .", +"format:check": "npx prettier -c .", +``` + +4. Make a commit. You should see that your files are being checked for rule breaks. If it does not work and you are using a Mac, run following command and try a new commit: + +```yaml +chmod ug+x .husky/* +``` diff --git a/README.md b/README.md index 49f576f6..eaf5124c 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ -# CyDig Pipeline Tasks +# CyDig Compliance Action -This repository contains compliance tasks. \ No newline at end of file +This repository contains a action with compliance controls. \ No newline at end of file diff --git a/__tests__/index.test.ts b/__tests__/index.test.ts deleted file mode 100644 index a9eeaa81..00000000 --- a/__tests__/index.test.ts +++ /dev/null @@ -1,7 +0,0 @@ -/** - * Unit tests for the action's entrypoint, src/index.ts - * - * These should be run as if the action was called from a workflow. - * Specifically, the inputs listed in `action.yml` should be set as environment - * variables following the pattern `INPUT_`. - */ diff --git a/action.yml b/action.yml index 4e4cb73d..235749ed 100644 --- a/action.yml +++ b/action.yml @@ -1,13 +1,7 @@ name: 'cydig/compliance@v1' -description: 'Provide a description here' +description: 'Cydig compliance action' author: 'Jonathan' -# Define your inputs here. -# inputs: -# subscription: -# description: 'SubscriptionId to use for the connections in the custom task.' -# required: true -# default: 'Not working' inputs: repo-token: description: 'SubscriptionId to use for the connections in the custom task.' diff --git a/package-lock.json b/package-lock.json index f14e5386..eda200c1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { - "name": "typescript-action", - "version": "0.0.0", + "name": "cydig-compliance-action", + "version": "1.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "typescript-action", - "version": "0.0.0", + "name": "cydig-compliance-action", + "version": "1.0.0", "license": "MIT", "dependencies": { "@actions/core": "^1.10.0", diff --git a/package.json b/package.json index 6668be2b..4fddd610 100644 --- a/package.json +++ b/package.json @@ -1,22 +1,9 @@ { - "name": "typescript-action", - "description": "GitHub Actions TypeScript template", - "version": "0.0.0", + "name": "cydig-compliance-action", + "description": "cydig-compliance-action", + "version": "1.0.0", "author": "", - "private": true, - "homepage": "https://github.com/actions/typescript-action", - "repository": { - "type": "git", - "url": "git+https://github.com/actions/typescript-action.git" - }, - "bugs": { - "url": "https://github.com/actions/typescript-action/issues" - }, - "keywords": [ - "actions", - "node", - "setup" - ], + "keywords": [], "exports": { ".": "./dist/index.js" }, @@ -24,14 +11,14 @@ "node": ">=16" }, "scripts": { - "bundle": "npm run format:write && npm run package", + "bundle": "npm run format:write && npm run build", "format:write": "prettier --write '**/*.ts'", "format:check": "prettier --check '**/*.ts'", "lint": "npx eslint . -c ./.github/linters/.eslintrc.yml", - "package": "ncc build src/index.ts --license licenses.txt", - "package:watch": "npm run package -- --watch", + "build": "ncc build src/index.ts --license licenses.txt", + "build:watch": "npm run build -- --watch", "test": "", - "all": "npm run format:write && npm run lint && npm run test && npm run package" + "all": "npm run format:write && npm run lint && npm run test && npm run build" }, "license": "MIT", "dependencies": { diff --git a/src/test/compliance-state-action.test.ts b/src/test/compliance-state-action.test.ts new file mode 100644 index 00000000..e69de29b diff --git a/tsconfig.json b/tsconfig.json index 2f80cc5c..3697a93a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,40 +11,8 @@ "noImplicitAny": true, "esModuleInterop": true, "forceConsistentCasingInFileNames": true, - // "strict": true, "skipLibCheck": true, "newLine": "lf" }, "exclude": ["./dist", "./node_modules", "./__tests__", "./coverage"] -} -// { -// "compilerOptions": { -// "target": "ES2021", -// "module": "commonjs", -// "outDir": "js_out", -// "sourceMap": true, -// "esModuleInterop": true, -// "skipLibCheck": true -// //"strict": true -// }, -// "include": ["**/*"], -// "exclude": ["node_modules", "**/*.js"] -// } - -//Prettier : .prettierrc.json -// { -// "printWidth": 80, -// "tabWidth": 2, -// "useTabs": false, -// "semi": false, -// "singleQuote": true, -// "quoteProps": "as-needed", -// "jsxSingleQuote": false, -// "trailingComma": "none", -// "bracketSpacing": true, -// "bracketSameLine": true, -// "arrowParens": "avoid", -// "proseWrap": "always", -// "htmlWhitespaceSensitivity": "css", -// "endOfLine": "lf" -// } \ No newline at end of file +} \ No newline at end of file