Skip to content

Commit

Permalink
feat(automation): add automation scripts for workflows and linters #32
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanjones243 committed Aug 31, 2023
1 parent 9a6a7d0 commit 5dff1b7
Show file tree
Hide file tree
Showing 12 changed files with 449 additions and 3 deletions.
5 changes: 5 additions & 0 deletions componentTemplates/linters/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": [
"@aurodesignsystem/eslint-config"
]
}
109 changes: 109 additions & 0 deletions componentTemplates/linters/.stylelintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
{
"extends": ["stylelint-config-recommended", "stylelint-config-idiomatic-order", "stylelint-config-standard-scss"],
"plugins": [
"stylelint-scss"
],
"rules": {
"alpha-value-notation": "number",
"at-rule-empty-line-before": [ "always", {
"except": [
"after-same-name",
"blockless-after-same-name-blockless",
"first-nested"
],
"ignore": [
"after-comment",
"blockless-after-blockless"
]
} ],
"at-rule-no-unknown": null,
"color-function-notation": "modern",
"color-named": "never",
"declaration-block-no-duplicate-custom-properties": true,
"declaration-block-no-duplicate-properties": true,
"declaration-block-no-redundant-longhand-properties": true,
"declaration-no-important": true,
"font-family-name-quotes": "always-where-recommended",
"font-weight-notation": "numeric",
"function-url-no-scheme-relative": true,
"function-url-quotes": "always",
"hue-degree-notation": "angle",
"max-nesting-depth": 2,
"named-grid-areas-no-invalid": true,
"no-empty-source": null,
"no-unknown-animations": true,
"no-invalid-position-at-import-rule": null,
"scss/at-else-closing-brace-newline-after": "always-last-in-chain",
"scss/at-else-closing-brace-space-after": "always-intermediate",
"scss/at-else-empty-line-before": "never",
"scss/at-else-if-parentheses-space-before": "always",
"scss/at-function-parentheses-space-before": "never",
"scss/at-if-closing-brace-newline-after": "always-last-in-chain",
"scss/at-if-closing-brace-space-after": "always-intermediate",
"scss/at-if-no-null": true,
"scss/at-import-partial-extension": null,
"scss/at-mixin-parentheses-space-before": "never",
"scss/at-rule-conditional-no-parentheses": true,
"scss/at-rule-no-unknown": true,
"scss/comment-no-empty": true,
"scss/declaration-nested-properties-no-divided-groups": true,
"scss/dollar-variable-colon-newline-after": "always-multi-line",
"scss/dollar-variable-colon-space-after": "always-single-line",
"scss/dollar-variable-colon-space-before": "never",
"scss/dollar-variable-empty-line-before": [
"always",
{
"except": [
"first-nested",
"after-dollar-variable"
],
"ignore": [
"after-comment",
"inside-single-line-block"
]
}
],
"scss/dollar-variable-first-in-block": [
true,
{
"ignore": [
"comments",
"imports"
]
}
],
"scss/dollar-variable-no-missing-interpolation": true,
"scss/double-slash-comment-whitespace-inside": "always",
"scss/map-keys-quotes": "always",
"scss/no-duplicate-dollar-variables": true,
"scss/no-duplicate-mixins": true,
"scss/no-global-function-names": true,
"scss/operator-no-newline-after": true,
"scss/operator-no-newline-before": true,
"scss/operator-no-unspaced": true,
"scss/selector-nest-combinators": "always",
"scss/selector-no-redundant-nesting-selector": true,
"selector-attribute-quotes": "always",
"selector-class-pattern": "^[a-z][a-zA-Z0-9]+$",
"selector-id-pattern": "^[a-z][a-zA-Z0-9]+$",
"selector-max-attribute": 1,
"selector-max-class": 1,
"selector-max-combinators": 1,
"selector-max-compound-selectors": 2,
"selector-max-id": 1,
"selector-max-pseudo-class": 2,
"selector-max-type": 1,
"selector-max-universal": 1,
"selector-no-qualifying-type": true,
"selector-pseudo-element-colon-notation": "single",
"selector-type-no-unknown": [
true,
{
"ignore": [
"custom-elements"
]
}
],
"shorthand-property-no-redundant-values": true
}
}
9 changes: 9 additions & 0 deletions componentTemplates/workflows/autoAssign.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: Issue assignment

on:
issues:
types: [opened]

jobs:
call-auro-assign-workflow:
uses: AlaskaAirlines/auro-library/.github/workflows/autoAssign.yml@main
58 changes: 58 additions & 0 deletions componentTemplates/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: "CodeQL"

on:
push:
branches: [ [branchName] ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ [branchName] ]

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'javascript' ]
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

steps:
- name: Checkout repository
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality


# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
# - name: Autobuild
# uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
46 changes: 46 additions & 0 deletions componentTemplates/workflows/testPublish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Test and publish

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the main branch
on:
push:
branches: [ [branchName] ]
pull_request:
branches: [ [branchName] ]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [ [abstractNodeVersion] ]

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm test

release:
# Only release on push to main
if: github.event_name == 'push' && github.ref == 'refs/heads/[branchName]'
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false
- uses: actions/setup-node@v3
with:
node-version: [abstractNodeVersion]
- run: npm ci
- run: npm run build:docs
- uses: cycjimmy/semantic-release-action@v3
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "This repository holds shared scripts, utilities, and workflows utilized acorss repositories along the Auro Design System.",
"repository": {
"type": "git",
"url": "git+https://github.com/AlaskaAirlines/auro-library.git"
"url": "https://github.com/AlaskaAirlines/auro-library.git"
},
"main": "index.js",
"license": "Apache-2.0",
Expand Down
46 changes: 46 additions & 0 deletions scripts/setup/syncAllTemplates.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env node

// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
// See LICENSE in the project root for license information.

// ---------------------------------------------------------------------

/**
* This script is for the purpose of keeping a component repository in sync with the latest set of workflows defined for Auro components.
* Running this script will delete all workflows that exist in the repository and replace them with the latest defined workflows for Auro components. **/

import AuroWorkflows from './syncWorkflows.mjs';
import AuroLinters from './syncLinters.mjs';

import AuroLibraryUtils from '../utils/auroLibraryUtils.mjs';

const auroWorkflows = new AuroWorkflows();
const auroLinters = new AuroLinters();

const auroLibraryUtils = new AuroLibraryUtils();

const args = process.argv.slice(2);

const message = ' RUNNING SYNC ALL CONFIGURATION SCRIPTS';

if (args.length > 0) {
const argsString = 'parameters:' + args.join(' ');

// Prints out message and parameter passed in through script call
auroLibraryUtils.auroLogger(`${message} \n ${argsString}`, 'info', true);
} else {
// Prints out message
auroLibraryUtils.auroLogger(message, 'info', true);
}

if (args.includes('--github')) {
// Run only github workflows script
auroWorkflows.copyWorkflowConfigurations();
} else if (args.includes('--linters')) {
// Run only linter configuration script
auroLinters.copyLintConfigurations();
} else {
// Run both configuration scripts
auroWorkflows.copyWorkflowConfigurations();
auroLinters.copyLintConfigurations();
}
26 changes: 26 additions & 0 deletions scripts/setup/syncLinters.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env node

// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
// See LICENSE in the project root for license information.

// ---------------------------------------------------------------------

/**
* This script is for the purpose of keeping a component repository in sync with the latest lint configurations defined for Auro components.
* Running this script will replace the current files with the latest defined configurations for Auro components.
* There is also an option to delete all existing files in the directory before copying over the latest lint configuration files. **/

import AuroLibraryUtils from "../utils/auroLibraryUtils.mjs";

const auroLibraryUtils = new AuroLibraryUtils();

export default class AuroLinters {
copyLintConfigurations() {
auroLibraryUtils.auroLogger(' SYNC TO LATEST LINT CONFIGURATIONS', 'info', true);

const srcDir = './node_modules/@aurodesignsystem/auro-library/componentTemplates/linters';
const destDir = './.github/linters';

auroLibraryUtils.copyDirectory(srcDir, destDir, false);
}
}
27 changes: 27 additions & 0 deletions scripts/setup/syncWorkflows.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env node

// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
// See LICENSE in the project root for license information.

// ---------------------------------------------------------------------

/**
* This script is for the purpose of keeping a component repository in sync with the latest set of github workflows defined for Auro components.
* Running this script will replace the current files with the latest defined github workflows for Auro components.
* There is also an option to delete all existing files in the directory before copying over the latest github workflow files. **/


import AuroLibraryUtils from "../utils/auroLibraryUtils.mjs";

const auroLibraryUtils = new AuroLibraryUtils();

export default class AuroWorkflows {
copyWorkflowConfigurations() {
auroLibraryUtils.auroLogger(' SYNC TO LATEST WORKFLOW CONFIGURATIONS', 'info', true);

const srcDir = './node_modules/@aurodesignsystem/auro-library/componentTemplates/workflows';
const destDir = './.github/workflows';

auroLibraryUtils.copyDirectory(srcDir, destDir, false);
}
}
File renamed without changes.
Loading

0 comments on commit 5dff1b7

Please sign in to comment.