Skip to content

Commit

Permalink
refactor: huge refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
stopsopa committed Aug 23, 2023
1 parent 3d5ad8d commit 90d9ade
Show file tree
Hide file tree
Showing 213 changed files with 14,619 additions and 17,929 deletions.
7 changes: 7 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
NODE_API_HOST="0.0.0.0"
NODE_API_PROTOCOL="http"
NODE_API_PORT=4275

CRASH_PORT="8087"

REPO_COVERALLS_URL="https://stopsopa.github.io/nlab/"
68 changes: 68 additions & 0 deletions .github/clean_before_artifact.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@

_SHELL="$(ps "${$}" | grep "${$} " | grep -v grep | sed -rn "s/.*[-\/]+(bash|z?sh) .*/\1/p")"; # bash || sh || zsh
case ${_SHELL} in
zsh)
_DIR="$( cd "$( dirname "${(%):-%N}" )" && pwd -P )"
_0="$( basename "${(%):-%N}" )"
_SCRIPT="${(%):-%N}"
_BINARY="/bin/zsh"
_PWD="$(pwd)"
;;
sh)
_DIR="$( cd "$( dirname "${0}" )" && pwd -P )"
_0="$( basename "${0}" )"
_SCRIPT="${0}"
_BINARY="/bin/sh"
_PWD="$(pwd)"
;;
*)
_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd -P )"
_0="$( basename "${BASH_SOURCE[0]}" )"
_SCRIPT="${BASH_SOURCE[0]}"
_BINARY="/bin/bash"
_PWD="$(pwd)"
;;
esac

cd "${_DIR}/.."

set -x
rm -rf .env*
rm -rf .git
rm -rf .github
rm -rf .gitignore
rm -rf .husky
rm -rf .npmignore
rm -rf .nvmrc
rm -rf .prettierignore
rm -rf .vscode
rm -rf bash
rm -rf colors.js
rm -rf combineReducers.js
rm -rf commitlint.config.js
rm -rf controller
rm -rf jest.config.js
rm -rf jest.sh
rm -rf jest.snapshotResolver.js
rm -rf LICENSE
rm -rf Makefile
rm -rf package.dev.json
rm -rf package.json
rm -rf playwright-async.config.js
rm -rf playwright-docker-defaults.sh
rm -rf playwright-report
rm -rf playwright.config.js
rm -rf playwright.sh
rm -rf prettier.config.cjs
rm -rf README.md
rm -rf release.config.js
rm -rf testall.sh
rm -rf yarn.lock

(
/bin/bash jasmine/clean_node_modules.sh
)

echo 'after clean_before_github_pages'

ls -la
7 changes: 7 additions & 0 deletions .github/pull-docker-image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

set -e
set -x
set -o pipefail
VERSION="$(SWAPQUIET=1 /bin/bash bash/swap-files-v2.sh package.json package.dev.json -- /bin/bash playwright.sh --version)"
echo ">${VERSION}<"
/bin/bash bash/swap-files-v2.sh package.json package.dev.json -- docker pull "mcr.microsoft.com/playwright:v${VERSION}-focal"
106 changes: 97 additions & 9 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,112 @@
name: Jest Tests
name: Tests
on:
push:
branches: [main, master]
branches:
- "**"
pull_request:
branches: [main, master]
branches:
- "**"

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: write # https://github.com/semantic-release/semantic-release/issues/2469#issuecomment-1158013884
pages: write
id-token: write

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # provided automatically by github itself https://docs.github.com/en/actions/security-guides/automatic-token-authentication
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} # search in keepassx
jobs:
tests:
timeout-minutes: 3
runs-on: ubuntu-20.04 # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#choosing-github-hosted-runners
test:
runs-on: ubuntu-22.04 # https://github.com/actions/runner-images#available-images
strategy:
fail-fast: false
matrix:
version: [14, 16, 18] # https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs
timeout-minutes: 60
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.version }}
- name: make yarn

- name: test before bringing cache
run: |
set -x
pwd
ls -la
ls -la node_modules || true
- uses: actions/cache/restore@v3 # https://github.com/actions/cache/blob/main/examples.md#node---yarn
id: restore-cache
with:
path: node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}

- name: test if cache revived?
run: |
set -x
pwd
ls -la
ls -la node_modules || true
- name: Yarn install
run: make yarn
- name: tests

- uses: actions/cache/save@v3 # https://github.com/actions/cache/blob/main/caching-strategies.md#reusing-primary-key-from-restore-cache-as-input-to-save-action
with:
path: node_modules
key: ${{ steps.restore-cache.outputs.cache-primary-key }}

- name: pulling playwright docker image
run: |
/bin/bash test.sh
/bin/bash .github/pull-docker-image.sh
- name: UNIT TESTS
run: |
/bin/bash jest.sh
- name: JASMINE TESTS
run: |
NODE_API_PORT=4273 /bin/bash jasmine/test.sh --env .env -- --target docker
- name: Clean before artifact
run: /bin/bash .github/clean_before_github_pages.sh

- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
path: .

# Deployment job
# github-pages:
# environment:
# name: github-pages
# url: ${{ steps.deployment.outputs.page_url }}
# runs-on: ubuntu-22.04
# needs: test
# steps:
# - name: Deploy to GitHub Pages
# id: deployment
# uses: actions/deploy-pages@v2

# npm:
# needs: test # https://docs.github.com/en/actions/using-jobs/using-jobs-in-a-workflow#defining-prerequisite-jobs
# if: github.ref == 'refs/heads/master'
# runs-on: ubuntu-22.04 # https://github.com/actions/runner-images#available-images
# timeout-minutes: 60
# steps:
# - uses: actions/checkout@v3
# - uses: actions/setup-node@v3
# with:
# node-version: 18

# - name: Install semantic-release
# run: /bin/bash bash/swap-files-v2.sh package.json package.dev.json -- yarn add semantic-release conventional-changelog-conventionalcommits
# # it has to be done here beacause otherwise it will crash for node@15 with error>>> error semantic-release@19.0.5: The engine "node" is incompatible with this module. Expected version ">=16 || ^14.17". Got "15.14.0"

# - name: npm pack
# run: npm pack
# # https://github.com/semantic-release/semantic-release/blob/master/docs/recipes/ci-configurations/github-actions.md
# - name: Release
# run: node node_modules/.bin/semantic-release --debug
9 changes: 7 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ node_modules
yarn-error*
/.idea/
/local.txt
/coverage/
/stopsopa-validator*
/karma_build/
/coverage/
*.jasmine-esbuild.js
/trash/
*.tgz
yarn-error*
/playwright-report/
.DS_Store
13 changes: 3 additions & 10 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,39 +1,32 @@
/test/jest/
/update.sh
/test/
/Makefile
/test.sh
/jest.sh
/update-badge.sh
/.travis.yml
/.prettierignore
/coverage/
/stopsopa-validator*
/local.txt
/.idea/
index.html
/server.js
/yarn.lock
/log/
node_modules
yarn-error*
/local.txt
/karma_build/
/dev/
/.github/workflows/playwright.yml
/.nvmrc
/prettier.config.cjs
/webpack/
/webpack-KARMA.config.js

/karma.conf.js
/karma.sh
/package_karma.json
/package.dev.json
/travis.sh
/webpack-UMD.config.js
/comment.txt
/todo.txt
/examples.es5.js
/examples.es6.js
/webpack-EXAMPLES.config.js
/bash/
.vscode/

Expand Down
4 changes: 1 addition & 3 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/webpack*
examples.es*
/coverage/
/dist/
karma.config.js
package_karma.json
package.dev.json
server.js
.github/workflows/playwright.yml
60 changes: 0 additions & 60 deletions .travis.yml

This file was deleted.

28 changes: 2 additions & 26 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,37 +1,13 @@
u: # update npm and git (generates new tag)
@/bin/bash update.sh

uf: # update even if there is nothing new committed
@/bin/bash update.sh force

h: # show any help that is available
@/bin/bash test.sh --help

t: # just run tests once
@/bin/bash test.sh

tw: # run tests in watch mode
@/bin/bash test.sh --watch

twa: # run tests in watchAll mode
@/bin/bash test.sh --watchAll
@/bin/bash jest.sh --help

c: # run local server to browse coverage
@node server.js --log 15 --dir coverage

nt: # test .npmignore
@npm pack

ck: # karma parameters.json
@/bin/bash update.sh --karma

cp: # jest parameters.json
@/bin/bash update.sh --prod

karma: # run karma test
@/bin/bash karma.sh
# /bin/bash karma.sh test/../file.test.js

umd: # build browser UMD versions
@node node_modules/.bin/webpack --config webpack-UMD.config.js

Expand All @@ -41,6 +17,6 @@ examples:
node examples.es5.js

yarn:
/bin/bash bash/swap-files-v2.sh package.json package_karma.json -- yarn --production=false
/bin/bash bash/swap-files-v2.sh package.json package.dev.json -- yarn --production=false


1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
![example workflow](https://github.com/stopsopa/validator/actions/workflows/playwright.yml/badge.svg)
[![npm version](https://badge.fury.io/js/%40stopsopa%2Fvalidator.svg)](https://badge.fury.io/js/%40stopsopa%2Fvalidator)
[![npm version](https://shields.io/npm/v/%40stopsopa%2Fvalidator)](https://www.npmjs.com/package/%40stopsopa%2Fvalidator)
[![NpmLicense](https://img.shields.io/npm/l/@stopsopa/validator.svg)](https://github.com/stopsopa/validator/blob/master/LICENSE)

## Table of Contents
Expand Down
Loading

0 comments on commit 90d9ade

Please sign in to comment.