Skip to content

Commit

Permalink
feat: first prototype
Browse files Browse the repository at this point in the history
  • Loading branch information
jackdbd committed May 28, 2021
1 parent 7cba2e4 commit f66dd31
Show file tree
Hide file tree
Showing 38 changed files with 24,453 additions and 10,792 deletions.
5 changes: 2 additions & 3 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
dist/
lib/
node_modules/
jest.config.js
dist/
coverage/
81 changes: 81 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
const github = {
name: 'github',
// the `plugin:github/recommended` preset configures 4 ESlint plugins.
// https://github.com/github/eslint-plugin-github/blob/main/lib/configs/recommended.js
// 1. https://github.com/github/eslint-plugin-github
// 2. https://github.com/prettier/eslint-plugin-prettier
// 3. https://github.com/mysticatea/eslint-plugin-eslint-comments
// 4. https://github.com/benmosher/eslint-plugin-import
extends: ['plugin:github/recommended'],
// additional rules and preset overrides
rules: {
// in rare occasions I want to disable ESlint with eslint-disable, but I
// definitely want to be reminded where this occurs.
'eslint-comments/no-use': 'warn',
'import/no-namespace': 'off'
}
}

const jest = {
name: 'jest',
// https://github.com/jest-community/eslint-plugin-jest#rules
extends: ['plugin:jest/recommended'],
// additional rules and preset overrides
rules: {
// I quite like todos in tests. I wonder why this is not a default.
'jest/prefer-todo': 'warn'
}
}

const typescript = {
name: '@typescript-eslint',
// https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin#recommended-configs
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking'
],
// https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/parser
parser: '@typescript-eslint/parser',
// additional rules and preset overrides. Many of these look like false
// positives to me.
// https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin#supported-rules
rules: {
'@typescript-eslint/no-unsafe-assignment': 'warn',
'@typescript-eslint/no-unsafe-member-access': 'warn',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/restrict-template-expressions': 'warn'
}
}

const config = {
// https://eslint.org/docs/user-guide/configuring/language-options#specifying-environments
env: {
es6: true,
node: true
},

extends: [
// the `eslint:recommended` preset configure many rules
// https://eslint.org/docs/rules/
'eslint:recommended',
...github.extends,
...jest.extends,
...typescript.extends
],

parser: typescript.parser,
parserOptions: {
project: ['./tsconfig.eslint.json']
},

plugins: [github.name, jest.name, typescript.name],

rules: {
...github.rules,
...jest.rules,
...typescript.rules,
'no-console': 'warn'
}
}

module.exports = config
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"eslint-comments/no-use": "off",
"import/no-namespace": "off",
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "error",
// "@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/explicit-member-accessibility": ["error", {"accessibility": "no-public"}],
"@typescript-eslint/no-require-imports": "error",
"@typescript-eslint/array-type": "error",
Expand Down
9 changes: 0 additions & 9 deletions .github/dependabot.yml

This file was deleted.

79 changes: 79 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: 'CI'

on:
pull_request:
paths-ignore:
- '**.md'
push:
branches:
- main
- 'releases/*'
paths-ignore:
- '**.md'

jobs:
build-and-test:
name: 📦 Bundle action on [${{ matrix.os }}, Node ${{ matrix.node }}]
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
node: ['12.x']
steps:
- name: 🛎️ Checkout repo
uses: actions/checkout@v2
- name: 🖥️ Setup Node.js ${{ matrix.node }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- name: 👨‍💻 Install dependencies
run: npm ci
- name: 🔍 Test
env:
INPUT_ENDPOINT: ${{ secrets.INPUT_ENDPOINT }}
INPUT_USERNAME: ${{ secrets.INPUT_USERNAME }}
INPUT_PASSWORD: ${{ secrets.INPUT_PASSWORD }}
INPUT_DOMAIN_ID: ${{ secrets.INPUT_DOMAIN_ID }}
run: npm run test:ci
- name: ⬆️ Upload coverage report to Coveralls
# https://github.com/coverallsapp/github-action
uses: coverallsapp/github-action@v1.1.2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

integration-test:
name: 📈 Run action without building
runs-on: ubuntu-latest
steps:
- name: 🛎️ Checkout repo
uses: actions/checkout@v2
- name: ⬇️ Fetch data from Ackee
id: ackee
uses: ./ # TODO: replace con jackdbd/ackee-action@v1 when published
with:
endpoint: ${{ secrets.INPUT_ENDPOINT }}
username: ${{ secrets.INPUT_USERNAME }}
password: ${{ secrets.INPUT_PASSWORD }}
domain_id: ${{ secrets.INPUT_DOMAIN_ID }}
num_top_pages: '5'
- name: Dump data
run: echo "${{ steps.ackee.outputs.data }}"
- name: 📨 Send report to Telegram
uses: appleboy/telegram-action@master
env:
ACKEE_REPORT: ${{ steps.ackee.outputs.data }}
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
message: |
🚀 Ackee report!
${{ env.ACKEE_REPORT }}
- name: 📨 Send report to Slack
uses: pullreminders/slack-action@master
env:
ACKEE_REPORT: ${{ steps.ackee.outputs.data }}
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
SLACK_CHANNEL_ID: ${{ secrets.SLACK_CHANNEL_ID }}
with:
args: '{\"channel\":\"${{ env.SLACK_CHANNEL_ID }}\",\"text\":\"${{ env.ACKEE_REPORT }}\"}'
24 changes: 0 additions & 24 deletions .github/workflows/test.yml

This file was deleted.

94 changes: 5 additions & 89 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,99 +1,15 @@
# Dependency directory
node_modules
# dependencies
node_modules/

# Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
# Test coverage
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# OS metadata
.DS_Store
Thumbs.db

# Ignore built ts files
__tests__/runner/*
lib/**/*
# environment variables
.envrc
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run lint
13 changes: 13 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

echo "PRE PUSH HOOK [destination remote: $1] [location remote: $2]"

# get the total-1 commits (to exclude the first, Initial commit)
n=$(git rev-list --count HEAD)
# echo "n ${n} n-1 $(expr $n - 1)"
from=$(printf HEAD~$(expr $n - 1))

echo "Run commitlint --from ${from} --to HEAD"
npx commitlint --from ${from} --to HEAD --verbose
# npx commitlint --print-config
9 changes: 5 additions & 4 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"arrowParens": "always",
"bracketSpacing": true,
"endOfLine": "lf",
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"semi": false,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "none",
"bracketSpacing": false,
"arrowParens": "avoid"
"useTabs": false
}
9 changes: 9 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"recommendations": [
"cschleiden.vscode-github-actions",
"eg2.vscode-npm-script",
"esbenp.prettier-vscode",
"graphql.vscode-graphql",
"pflannery.vscode-versionlens"
]
}
21 changes: 21 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"files.exclude": {
"**/node_modules/": true
},

"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
"[markdown]": {
"editor.suggestOnTriggerCharacters": false
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
}
}
Loading

0 comments on commit f66dd31

Please sign in to comment.