diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml new file mode 100644 index 00000000..9fbd2723 --- /dev/null +++ b/.github/actions/build/action.yml @@ -0,0 +1,11 @@ +name: Build +description: Run Build +runs: + using: "composite" + steps: + - name: Install deps + run: npm ci --silent + shell: bash + - name: Build and package the application + run: npm pack + shell: bash diff --git a/.github/actions/es-lint/action.yml b/.github/actions/es-lint/action.yml new file mode 100644 index 00000000..16a581eb --- /dev/null +++ b/.github/actions/es-lint/action.yml @@ -0,0 +1,11 @@ +name: ESLint +description: Run ESLint +runs: + using: "composite" + steps: + - name: Install deps + run: npm ci --silent + shell: bash + - name: Run lint tests + run: npm run --silent test:lint + shell: bash diff --git a/.github/actions/functional-test/action.yml b/.github/actions/functional-test/action.yml new file mode 100644 index 00000000..9b4044bb --- /dev/null +++ b/.github/actions/functional-test/action.yml @@ -0,0 +1,16 @@ +name: Functional Tests +description: Run Functional Tests +inputs: + test-set: + description: Test set to run + required: true +runs: + using: "composite" + steps: + - name: Run functional test + run: | + cd package + npm install --silent + features/run-kuzzle-stack.sh + npm run test:functional:${{ inputs.test-set }} + shell: bash diff --git a/.github/workflows/pull_request.workflow.yml b/.github/workflows/pull_request.workflow.yml new file mode 100644 index 00000000..aa86f055 --- /dev/null +++ b/.github/workflows/pull_request.workflow.yml @@ -0,0 +1,88 @@ +name: Run tests + +on: [pull_request] + +jobs: + lint: + name: Lint + runs-on: ubuntu-18.04 + steps: + - uses: actions/checkout@v2 + - name: Cache node modules + uses: actions/cache@v2 + env: + cache-name: cache-node-modules + with: + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + - uses: actions/setup-node@v1.4.4 + with: + node-version: 12 + - uses: ./.github/actions/es-lint + + build: + name: Build + runs-on: ubuntu-18.04 + needs: [lint] + steps: + - uses: actions/checkout@v2 + - name: Cache node modules + uses: actions/cache@v2 + env: + cache-name: cache-node-modules + with: + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + - uses: actions/setup-node@v1.4.4 + with: + node-version: 12 + - uses: ./.github/actions/build + - name: Store build archive as artifact + uses: actions/upload-artifact@v2 + with: + name: kourou-build + path: ./kourou-*.tgz + + functional-test: + name: Functional Test - ${{ matrix.test-set }} + runs-on: ubuntu-18.04 + needs: [build] + strategy: + matrix: + test-set: [stdout, cucumber] + steps: + - uses: actions/checkout@v2 + - name: Cache node modules + uses: actions/cache@v2 + env: + cache-name: cache-node-modules + NODE_ENV: test + with: + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + - uses: actions/setup-node@v1.4.4 + with: + node-version: 12 + - name: Recover previously built Kourou + uses: actions/download-artifact@v2 + with: + name: kourou-build + - name: Unpack and prepare artifact for tests + run: | + tar xfz ./kourou-*.tgz + cp -fr .mocharc.json .nycrc tsconfig.json features test package/ + - uses: ./.github/actions/functional-test + with: + test-set: ${{ matrix.test-set }} diff --git a/.github/workflows/push_dev.workflow.yml b/.github/workflows/push_dev.workflow.yml new file mode 100644 index 00000000..897d84d6 --- /dev/null +++ b/.github/workflows/push_dev.workflow.yml @@ -0,0 +1,91 @@ +name: Run tests + +on: + push: + branches: + - develop + +jobs: + lint: + name: Lint + runs-on: ubuntu-18.04 + steps: + - uses: actions/checkout@v2 + - name: Cache node modules + uses: actions/cache@v2 + env: + cache-name: cache-node-modules + with: + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + - uses: actions/setup-node@v1.4.4 + with: + node-version: 12 + - uses: ./.github/actions/es-lint + + build: + name: Build + runs-on: ubuntu-18.04 + needs: [lint] + steps: + - uses: actions/checkout@v2 + - name: Cache node modules + uses: actions/cache@v2 + env: + cache-name: cache-node-modules + with: + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + - uses: actions/setup-node@v1.4.4 + with: + node-version: 12 + - uses: ./.github/actions/build + - name: Store build archive as artifact + uses: actions/upload-artifact@v2 + with: + name: kourou-build + path: ./kourou-*.tgz + + functional-test: + name: Functional Test - ${{ matrix.test-set }} + runs-on: ubuntu-18.04 + needs: [build] + strategy: + matrix: + test-set: [stdout, cucumber] + steps: + - uses: actions/checkout@v2 + - name: Cache node modules + uses: actions/cache@v2 + env: + cache-name: cache-node-modules + NODE_ENV: test + with: + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + - uses: actions/setup-node@v1.4.4 + with: + node-version: 12 + - name: Recover previously built Kourou + uses: actions/download-artifact@v2 + with: + name: kourou-build + - name: Unpack and prepare artifact for tests + run: | + tar xfz ./kourou-*.tgz + cp -fr .mocharc.json .nycrc tsconfig.json features test package/ + - uses: ./.github/actions/functional-test + with: + test-set: ${{ matrix.test-set }} diff --git a/.github/workflows/push_master.workflow.yml b/.github/workflows/push_master.workflow.yml new file mode 100644 index 00000000..87a90277 --- /dev/null +++ b/.github/workflows/push_master.workflow.yml @@ -0,0 +1,106 @@ +name: Run tests + +on: + push: + branches: + - master + +jobs: + lint: + name: Lint + runs-on: ubuntu-18.04 + steps: + - uses: actions/checkout@v2 + - name: Cache node modules + uses: actions/cache@v2 + env: + cache-name: cache-node-modules + with: + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + - uses: actions/setup-node@v1.4.4 + with: + node-version: 12 + - uses: ./.github/actions/es-lint + + build: + name: Build + runs-on: ubuntu-18.04 + needs: [lint] + steps: + - uses: actions/checkout@v2 + - name: Cache node modules + uses: actions/cache@v2 + env: + cache-name: cache-node-modules + with: + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + - uses: actions/setup-node@v1.4.4 + with: + node-version: 12 + - uses: ./.github/actions/build + - name: Store build archive as artifact + uses: actions/upload-artifact@v2 + with: + name: kourou-build + path: ./kourou-*.tgz + + functional-test: + name: Functional Test - ${{ matrix.test-set }} + runs-on: ubuntu-18.04 + needs: [build] + strategy: + matrix: + test-set: [stdout, cucumber] + steps: + - uses: actions/checkout@v2 + - name: Cache node modules + uses: actions/cache@v2 + env: + cache-name: cache-node-modules + NODE_ENV: test + with: + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + - uses: actions/setup-node@v1.4.4 + with: + node-version: 12 + - name: Recover previously built Kourou + uses: actions/download-artifact@v2 + with: + name: kourou-build + - name: Unpack and prepare artifact for tests + run: | + tar xfz ./kourou-*.tgz + cp -fr .mocharc.json .nycrc tsconfig.json features test package/ + - uses: ./.github/actions/functional-test + with: + test-set: ${{ matrix.test-set }} + + deploy: + name: Deploy to NPM.js + runs-on: ubuntu-18.04 + needs: [functional-test] + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: 12 + registry-url: "https://registry.npmjs.org" + - run: npm install + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index ade434b0..00000000 --- a/.travis.yml +++ /dev/null @@ -1,112 +0,0 @@ -jobs: - include: - - stage: Tests - name: "Kourou TS build" - language: node_js - node_js: 12 - cache: - directories: - - ~/.npm - - ~/.cache - - node_modules # NPM packages - - install: - - npm install --silent --unsafe-perm - - npm install --silent --unsafe-perm --only=dev - - script: - - npm run prepack - - - stage: Tests - name: "Kourou Lint" - language: node_js - node_js: 12 - cache: - directories: - - ~/.npm - - ~/.cache - - node_modules # NPM packages - - install: - - npm install --silent --unsafe-perm - - npm install --silent --unsafe-perm --only=dev - - script: - - npm run test:lint - - - stage: Tests - name: "Kourou Functional Stdout Tests" - language: node_js - node_js: 12 - cache: - directories: - - ~/.npm - - ~/.cache - - node_modules # NPM packages - env: - - KOUROU_RUNTIME="./package/bin/run" - - install: - # install kourou dependencies for packing and testing - - npm install --silent --unsafe-perm - # create npm package - - npm pack - # extract to ./package/ - - tar xf kourou-$(node -e 'console.log(require("./package.json").version)').tgz - # install kourou production dependencies for package - - npm install --prefix package --silent --unsafe-perm --only production - # ensure tests always use the generated package - - rm -rf ./bin - - script: - - npm run test:functional:stdout - - - stage: Tests - name: "Kourou Functional Cucumber Tests" - language: node_js - node_js: 12 - cache: - directories: - - ~/.npm - - ~/.cache - - node_modules # NPM packages - env: - - KOUROU_RUNTIME="./package/bin/run" - - NODE_ENV=test - - install: - # install kourou dependencies for packing and testing - - npm install --silent --unsafe-perm - # create npm package - - npm pack - # extract to ./package/ - - tar xf kourou-$(node -e 'console.log(require("./package.json").version)').tgz - # install kourou production dependencies for package - - npm install --prefix package --silent --unsafe-perm --only production - # ensure tests always use the generated package - - rm -rf ./bin - - script: - - bash features/run-kuzzle-stack.sh - - npm run test:functional:cucumber - after_failure: - - docker-compose -f features/docker/docker-compose.yml logs - - - stage: Deploy - name: Deploy Kourou on NPM - if: type = push AND branch = master - sudo: false - language: node_js - node_js: 12 - install: - - npm install - deploy: - edge: true - provider: npm - skip_cleanup: true - email: support@kuzzle.io - api_key: - secure: "J1JpQS8HNaA3HSnSD5HQWiWTGaAk5PapaZNCBMSDhoRo+bgROS64B/eVFLY+qIlilSleRbJ8My2Wh1Iv6vqg4/M0NGTzfkRPbqFW5LD/gXj9Am+r7K5M3S0q48aplPSYS+cBVhxlQAL/pLBUryxwGIvcGYI0GMY6S91nNKVdh/meGOJOpQgr+6TVBua8gvAHONckEu/d8iPv3YDsR3McIDAvLVgHxmRNC4iF5UcUnqsTEWiF23DJEAH7g5cjEcLBLJ+76WLIF2whmjFuc+JIvFBNws2IGPLA5ycjIbJYzDdA6v9Db8FdmfSgQLU660tmd/hVLaUI7P+Db2wthVm3Tk0BWjlnVQnzYPEC4klu+RhhGuK3icrTJ6ljWnbkMXGhP0L21NMiFpY9QfjW03T//d4h+kqLtrFo97xfZ1iPPzy7Lpzycb3dwDIPya/Bqi8xLuMS7jyJuAxaissFRNE3sTmXKS+IkjHgkSlh8t1Cc1DacDO7flGH6o/7TPtiKaTu8E92uzHuOvx4lqwxrkWpy3PBH6j1TsgFLk8oJbUcStuG3Bt4JU/j/y/8vIgjxlcueqyVRv7wwpxUlIRz66Qxz6Ygoo4/OSue+UGNFVEvBYZW9+F2nr/62v2BLbVWCfXjnGyDTZsmTtleBOjFk2JIAKupgIsz8LnBdXvVOot2USI=" - on: - repo: kuzzleio/kourou - all_branches: true diff --git a/tsconfig.json b/tsconfig.json index 64709880..e9b1e299 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,5 @@ { "compilerOptions": { - "noUncheckedIndexedAccess": true, "declaration": true, "importHelpers": true, "module": "commonjs",