Skip to content

Commit

Permalink
Convert build to use github actions (#78)
Browse files Browse the repository at this point in the history
* Move PR template into .github directory

* first pass at github actions for test runs and npm publish

* update node version to current LTS

* update .npmignore file

* bump dependencies

* trying docker setup

* workflow updates and deps upgrades including eslint

* no need for eslintrc

* warn only on outdated deps

* no more drone

* minor tweaks to publish workflow

* removing docker deploy from postversion script

---------

Co-authored-by: Rajesh Susai <raj.susai@meltwater.com>
  • Loading branch information
mattquinlan440 and rajeshsusai authored Oct 16, 2024
1 parent c150cbb commit 3a532ed
Show file tree
Hide file tree
Showing 14 changed files with 989 additions and 921 deletions.
49 changes: 0 additions & 49 deletions .drone.yml

This file was deleted.

216 changes: 108 additions & 108 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,113 +1,113 @@
{
// http://eslint.org/docs/rules/
"env": {
"jasmine": true,
"node": true
},
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module"
},

"extends": "eslint:recommended",
"rules": {
"valid-jsdoc": "error",
"default-case": "error",
"id-length": [
"error",
{
"min": 2,
"exceptions": ["id"]
}
],
"no-alert": "error",
"no-implicit-coercion": "error",
"no-implied-eval": "error",
"no-invalid-this": "error",
"no-labels": "error",
"no-lone-blocks": "error",
"no-loop-func": "error",
"no-magic-numbers": [
"error",
{
"ignore": [0, 1, 2]
}
],
"no-param-reassign": "error",
"no-prototype-builtins": "off",
"no-return-assign": ["error", "always"],
"no-script-url": "error",
"no-self-compare": "error",
"no-sequences": "error",
"no-throw-literal": "error",
"no-unmodified-loop-condition": "error",
"no-unused-expressions": "error",
"no-useless-call": "error",
"no-useless-concat": "error",
"no-useless-return": "error",
"no-void": "error",
"no-with": "error",

/**
* Stylistic rules
*/

"camelcase": "error",
"complexity": "error",
"curly": [
"error",
"all"
],
"max-depth": [
"error",
3 // http://eslint.org/docs/rules/max-depth
],
"new-cap": "error",
"new-parens": "error",
"no-continue": "error",
"no-lonely-if": "error",
"no-multiple-empty-lines": [
// http://eslint.org/docs/rules/
"env": {
"jasmine": true,
"node": true
},
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module"
},

"extends": "eslint:recommended",
"rules": {
"valid-jsdoc": "error",
"default-case": "error",
"id-length": [
"error",
{
"max": 1
"min": 2,
"exceptions": ["id"]
}
],
"no-nested-ternary": "error",
"no-tabs": "error",
"no-trailing-spaces": [
"error",
{
"ignoreComments": true,
"skipBlankLines": true
}
],
"no-unneeded-ternary": "error",
"nonblock-statement-body-position": [
"error",
"beside" // http://eslint.org/docs/rules/nonblock-statement-body-position
],
"one-var-declaration-per-line": [
"error",
"always"
],
"semi": [
"error",
"always"
],
"vars-on-top": "error",

/**
* ES6 Specific
],
"no-alert": "error",
"no-implicit-coercion": "error",
"no-implied-eval": "error",
"no-invalid-this": "error",
"no-labels": "error",
"no-lone-blocks": "error",
"no-loop-func": "error",
"no-magic-numbers": [
"error",
{
"ignore": [0, 1, 2]
}
],
"no-param-reassign": "error",
"no-prototype-builtins": "off",
"no-return-assign": ["error", "always"],
"no-script-url": "error",
"no-self-compare": "error",
"no-sequences": "error",
"no-throw-literal": "error",
"no-unmodified-loop-condition": "error",
"no-unused-expressions": "error",
"no-useless-call": "error",
"no-useless-concat": "error",
"no-useless-return": "error",
"no-void": "error",
"no-with": "error",

/**
* Stylistic rules
*/

"arrow-body-style": [
"error",
"as-needed"
],
"no-confusing-arrow": "error",
"no-useless-constructor": "error",
"no-var": "error",
"prefer-const": "error",
"prefer-template": "error"
}
}

"camelcase": "error",
"complexity": "error",
"curly": [
"error",
"all"
],
"max-depth": [
"error",
3 // http://eslint.org/docs/rules/max-depth
],
"new-cap": "error",
"new-parens": "error",
"no-continue": "error",
"no-lonely-if": "error",
"no-multiple-empty-lines": [
"error",
{
"max": 1
}
],
"no-nested-ternary": "error",
"no-tabs": "error",
"no-trailing-spaces": [
"error",
{
"ignoreComments": true,
"skipBlankLines": true
}
],
"no-unneeded-ternary": "error",
"nonblock-statement-body-position": [
"error",
"beside" // http://eslint.org/docs/rules/nonblock-statement-body-position
],
"one-var-declaration-per-line": [
"error",
"always"
],
"semi": [
"error",
"always"
],
"vars-on-top": "error",

/**
* ES6 Specific
*/

"arrow-body-style": [
"error",
"as-needed"
],
"no-confusing-arrow": "error",
"no-useless-constructor": "error",
"no-var": "error",
"prefer-const": "error",
"prefer-template": "error"
}
}
File renamed without changes.
23 changes: 23 additions & 0 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Node.js CI test

on: [push]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x, 18.x, 20.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm test
64 changes: 64 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: NPM Pipeline

on:
workflow_run:
workflows: ["Node.js CI test"]
types:
- completed
push:
tags:
- "v*"

jobs:
Publish:
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: "npm"
registry-url: https://registry.npmjs.org
cache-dependency-path: package-lock.json
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}

- name: Install dependencies
run: npm ci

- name: Publish package
run: npm publish

- name: Build package
run: scripts/build-packages

- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: awsudo:${{github.ref_name}}
path: awsudo-${{github.ref_name}}.tgz

Deploy_Docker_Image:
runs-on: ubuntu-latest
needs: Publish
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')

steps:
- name: Download build artifact
uses: actions/download-artifact@v4
with:
name: awsudo:${{github.ref_name}}

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build Docker image
run: scripts/deploy-docker
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
docker/
scripts/

.github
.drone.yml
.editorconfig
.eslintrc
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
lts/fermium
lts/iron
Loading

0 comments on commit 3a532ed

Please sign in to comment.