Skip to content

Commit

Permalink
Merge pull request #19 from PermanentOrg/typescript-setup
Browse files Browse the repository at this point in the history
Typescript project setup
  • Loading branch information
meisekimiu authored Aug 4, 2023
2 parents 91c95e1 + c55d1b4 commit 95d8444
Show file tree
Hide file tree
Showing 12 changed files with 4,998 additions and 16 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/lint-js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Lint (TypeScript)

on:
pull_request:
workflow_dispatch:

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: "18"
- uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node_modules-
- name: Install dependencies
run: npm install
working-directory: js
- name: Run eslint
run: npm run lint
working-directory: js
32 changes: 16 additions & 16 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@ name: Test

on:
push:
branches:
branches:
- main
pull_request:
paths-ignore:
- "js/**"

jobs:
execute:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: pip install -r requirements-dev.txt
- name: Run formatter
run: black --check permanent_upload
- name: Run package help
run: python3 -m permanent_upload -h


execute:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-python@v2
with:
python-version: "3.x"
- name: Install dependencies
run: pip install -r requirements-dev.txt
- name: Run formatter
run: black --check permanent_upload
- name: Run package help
run: python3 -m permanent_upload -h
29 changes: 29 additions & 0 deletions js/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const path = require("path");

module.exports = {
parser: "@typescript-eslint/parser",
parserOptions: {
project: path.join(__dirname, "tsconfig.json"),
},
plugins: ["@typescript-eslint", "import", "prettier", "cypress"],
extends: [
"plugin:@typescript-eslint/all",
"airbnb-base",
"airbnb-typescript/base",
"prettier",
"plugin:cypress/recommended",
],
rules: {
"import/prefer-default-export": "off",
"import/no-default-export": "off",
"@typescript-eslint/prefer-readonly-parameter-types": "off",
"prettier/prettier": "error",
"@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_" }],
"@typescript-eslint/no-unused-expressions": "off",
},
ignorePatterns: [".eslintrc.js"],
env: {
es6: true,
node: true,
},
};
134 changes: 134 additions & 0 deletions js/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-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
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
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

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

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp
.cache

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

# Cypress
cypress/videos
cypress/screenshots
15 changes: 15 additions & 0 deletions js/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# End-to-End Functional Test

The `js` directory contains the in-development replacement for the Permanent Functional Test. It uses end-to-end testing via Cypress to test functionality rather than hitting the API directly.

Currently it exists in a subdirectory since the plan is to eventually completely replace the Python project in this repository, rather than make a new one.

## Setup

Run `npm install` to install dependencies.

## Running Tests

To run headless tests, simply run `npm start`.

To run tests in the Cypress UI, run `npm run cypress:open`.
10 changes: 10 additions & 0 deletions js/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { defineConfig } from "cypress";

export default defineConfig({
e2e: {
setupNodeEvents(_on, _config) {
// implement node event listeners here
},
video: false,
},
});
5 changes: 5 additions & 0 deletions js/cypress/e2e/health.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
describe("health check spec", () => {
it("works", () => {
expect(true).to.be.true;
});
});
37 changes: 37 additions & 0 deletions js/cypress/support/commands.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/// <reference types="cypress" />
// ***********************************************
// This example commands.ts shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add('login', (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
//
// declare global {
// namespace Cypress {
// interface Chainable {
// login(email: string, password: string): Chainable<void>
// drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
// }
// }
// }
20 changes: 20 additions & 0 deletions js/cypress/support/e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// ***********************************************************
// This example support/e2e.ts is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import "./commands";

// Alternatively you can use CommonJS syntax:
// require('./commands')
Loading

0 comments on commit 95d8444

Please sign in to comment.