Skip to content

Instantly share code, notes, and snippets.

View Roms1383's full-sized avatar
😊
I might not be available to respond, but I'll do my best !

Rom's Roms1383

😊
I might not be available to respond, but I'll do my best !
  • Chiang Mai, Thailand
View GitHub Profile
@Roms1383
Roms1383 / index.test.js
Last active November 17, 2019 07:14
Integration tests of a MESG Service on GitHub Actions ✅
require('dotenv').config()
const Client = require('pusher-js')
const MESG = require('mesg-js').application()
const execute = async ({ taskKey, params, instanceHash }) => {
const { outputs } = await MESG.executeTaskAndWaitResult({
taskKey,
inputs: MESG.encodeData(params),
instanceHash
})
return MESG.decodeData(outputs)
@Roms1383
Roms1383 / main.yml
Last active November 17, 2019 07:14
Integration tests of a MESG Service on GitHub Actions ✅
name: build
on: [push]
env:
NPM: '6.12.0'
YARN: '1.19.1'
CI: true
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
@Roms1383
Roms1383 / package.json
Created November 15, 2019 07:22
Integration tests of a MESG Service on GitHub Actions ✅
{
"name": "mesg-pusher",
"version": "0.0.0-semantically-released",
"description": "MESG Service to interact with Pusher",
"main": "index.js",
"repository": "https://github.com/Roms1383/mesg-pusher.git",
"author": "Romain KELIFA",
"license": "MIT",
"files": [
"**/!(*.spec|*.test|*.config).js",
@Roms1383
Roms1383 / pretest.sh
Created November 15, 2019 07:43
Integration tests of a MESG Service on GitHub Actions ✅
#!/bin/sh
npx rimraf ~/.mesg
mesg-cli daemon:start
mesg-cli account:create $MESG_ACCOUNT --passphrase $MESG_PASSPHRASE --quiet
mesg-cli service:create "$(mesg-cli service:compile --quiet)" --account $MESG_ACCOUNT --passphrase $MESG_PASSPHRASE --quiet > MESG_SERVICE_HASH.txt
mesg-cli service:start "$(cat MESG_SERVICE_HASH.txt)" --env PUSHER_APP_ID=$PUSHER_APP_ID --env PUSHER_APP_KEY=$PUSHER_APP_KEY --env PUSHER_APP_SECRET=$PUSHER_APP_SECRET --env PUSHER_CLUSTER=$PUSHER_CLUSTER --quiet > MESG_INSTANCE_HASH.txt
@Roms1383
Roms1383 / posttest.sh
Created November 15, 2019 07:48
Integration tests of a MESG Service on GitHub Actions ✅
#!/bin/sh
mesg-cli service:stop "$(cat MESG_INSTANCE_HASH.txt)"
mesg-cli daemon:stop
rm -f ./MESG_SERVICE_HASH.txt
rm -f ./MESG_INSTANCE_HASH.txt
@Roms1383
Roms1383 / conditional-removal.sh
Last active January 12, 2020 09:23
handle Serverless provisioning from Terraform
#!/bin/bash
# $1 is the name of the repository
# $2 is the optional tag of the repository
REMOVE=$(node should-remove.js microservice)
if [[ $REMOVE == "true" ]]; then
git clone https://github.com/owner/$1.git
cd $1/
if [ "$2" != "" ]; then
@Roms1383
Roms1383 / jest.config.js
Created January 16, 2020 03:40
Medium - Dynamically matching files in Jest - using CLI regexp
module.exports = {
roots: [
'<rootDir>/dist/',
],
testEnvironment: 'node',
transform: {
'^.+\\.(ts|tsx)$': 'ts-jest',
},
}
@Roms1383
Roms1383 / jest.config.integration.only.js
Last active January 16, 2020 04:47
Medium - Dynamically matching files in Jest - using different configuration files
module.exports = {
...require('./jest.config'),
testMatch: ['**/?(*.)+(test).js']
}
@Roms1383
Roms1383 / .env
Created January 16, 2020 05:11
Medium - Dynamically matching files in Jest - using environment variable
JEST_FILES_PATTERN="spec"
// or JEST_FILES_PATTERN="test"
// or JEST_FILES_PATTERN="spec|test"
@Roms1383
Roms1383 / main.tf
Last active January 19, 2020 06:43
Medium - Mate Terraform and Serverless
module "sls_user" {
source = "./microservice"
microservice_version = "1.0.0"
}
module "sls_product" {
source = "./microservice"
microservice_version = "1.0.0"
# microservice_active = false
}