Skip to content

Commit

Permalink
Add API for content fetching (#135)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcospassos authored Nov 18, 2022
1 parent 19d1f02 commit fe4ab87
Show file tree
Hide file tree
Showing 54 changed files with 24,476 additions and 12,834 deletions.
74 changes: 63 additions & 11 deletions .github/workflows/deploy-published-releases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,26 @@ env:
CDN_URL: https://cdn.croct.io/js/v1/lib/plug.js
PLAYGROUND_ORIGIN: https://play.croct.com
PLAYGROUND_CONNECT_URL: https://play.croct.com/connect.html
PREVIEW_WIDGET_ORIGIN: https://cdn.croct.io
PREVIEW_WIDGET_PATH: js/v1/lib/plug/widget-${{ github.ref_name }}.html
PREVIEW_WIDGET_URL: https://cdn.croct.io/js/v1/lib/plug/widget-${{ github.ref_name }}.html

jobs:
deploy:
runs-on: ubuntu-18.04
deploy-library:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 12
node-version: 16

- name: Cache dependencies
id: cache-dependencies
uses: actions/cache@v1
with:
path: node_modules
key: node_modules-${{ hashFiles('**/package-lock.json', '**/package.json') }}
key: node_modules-${{ hashFiles('package-lock.json') }}

- name: Install dependencies
if: steps.cache-dependencies.outputs.cache-hit != 'true'
run: |-
Expand All @@ -40,12 +44,11 @@ jobs:
cp package.json LICENSE README.md build/
cd build
sed -i -e "s~\"version\": \"0.0.0-dev\"~\"version\": \"${GITHUB_REF##*/}\"~" package.json
sed -i -e "s~<@cdnUrl@>~${CDN_URL}~" constants.js
sed -i -e "s~<@cdnUrl@>~${CDN_URL}~" constants.d.ts
sed -i -e "s~<@playgroundOrigin@>~${PLAYGROUND_ORIGIN}~" constants.js
sed -i -e "s~<@playgroundOrigin@>~${PLAYGROUND_ORIGIN}~" constants.d.ts
sed -i -e "s~<@playgroundConnectUrl@>~${PLAYGROUND_CONNECT_URL}~" constants.js
sed -i -e "s~<@playgroundConnectUrl@>~${PLAYGROUND_CONNECT_URL}~" constants.d.ts
sed -i -e "s~<@cdnUrl@>~${CDN_URL}~" constants.*
sed -i -e "s~<@playgroundOrigin@>~${PLAYGROUND_ORIGIN}~" constants.*
sed -i -e "s~<@playgroundConnectUrl@>~${PLAYGROUND_CONNECT_URL}~" constants.*
sed -i -e "s~<@previewWidgetOrigin@>~${PREVIEW_WIDGET_ORIGIN}~" constants.*
sed -i -e "s~<@previewWidgetUrl@>~${PREVIEW_WIDGET_URL}~" constants.*
- name: Publish pre-release to NPM
if: ${{ github.event.release.prerelease }}
Expand All @@ -71,18 +74,67 @@ jobs:
rm -rf build
npm run bundle -- --config-cdn-url=${CDN_URL} \
--config-playground-origin=${PLAYGROUND_ORIGIN} \
--config-playground-connect-url=${PLAYGROUND_CONNECT_URL}
--config-playground-connect-url=${PLAYGROUND_CONNECT_URL} \
--config-preview-widget-origin=${PREVIEW_WIDGET_ORIGIN} \
--config-preview-widget-url=${PREVIEW_WIDGET_URL}
- name: Authenticate to GCP
if: ${{ !github.event.release.prerelease }}
uses: google-github-actions/[email protected]
with:
credentials_json: ${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}

- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v0

- name: Deploy to GCS
if: ${{ !github.event.release.prerelease }}
env:
GCLOUD_BUCKET: ${{ secrets.GCLOUD_BUCKET }}
run: |-
gsutil -m cp build/plug.min.js "gs://${GCLOUD_BUCKET}/js/v1/lib/plug.js"
gsutil -m setmeta -h "Cache-Control: public, max-age=3600" "gs://${GCLOUD_BUCKET}/js/v1/lib/plug.js"
deploy-preview-widget:
runs-on: ubuntu-latest
defaults:
run:
working-directory: preview
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 16

- name: Cache dependencies
id: cache-dependencies
uses: actions/cache@v1
with:
path: node_modules
key: node_modules-${{ hashFiles('package-lock.json') }}

- name: Install dependencies
if: steps.cache-dependencies.outputs.cache-hit != 'true'
run: |-
npm ci
- name: Build package
run: |-
npm run build
- name: Authenticate to GCP
if: ${{ !github.event.release.prerelease }}
uses: google-github-actions/[email protected]
with:
credentials_json: ${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}

- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v0

- name: Deploy to GCS
if: ${{ !github.event.release.prerelease }}
env:
GCLOUD_BUCKET: ${{ secrets.GCLOUD_BUCKET }}
run: |-
gsutil -m cp dist/widget.html "gs://${GCLOUD_BUCKET}/${PREVIEW_WIDGET_PATH}"
gsutil -m setmeta -h "Cache-Control: public, max-age=3600" "gs://${GCLOUD_BUCKET}/${PREVIEW_WIDGET_PATH}"
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Validations
name: Library validations

on:
push:
Expand All @@ -12,42 +12,42 @@ on:
- opened

jobs:
# security-checks:
# runs-on: ubuntu-18.04
# steps:
# - uses: actions/checkout@v1
# - uses: actions/setup-node@v1
# with:
# node-version: 12

# - name: Cache dependencies
# id: cache-dependencies
# uses: actions/cache@v1
# with:
# path: node_modules
# key: node_modules-${{ hashFiles('**/package-lock.json') }}

# - name: Install dependencies
# if: steps.cache-dependencies.outputs.cache-hit != 'true'
# run: npm ci

# - name: Check dependency vulnerabilities
# run: npm audit
security-checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 16

- name: Cache dependencies
id: cache-dependencies
uses: actions/cache@v1
with:
path: node_modules
key: node_modules-${{ hashFiles('package-lock.json') }}

- name: Install dependencies
if: steps.cache-dependencies.outputs.cache-hit != 'true'
run: npm ci

- name: Check dependency vulnerabilities
run: npm audit

validate:
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 12
node-version: 16

- name: Cache dependencies
id: cache-dependencies
uses: actions/cache@v1
with:
path: node_modules
key: node_modules-${{ hashFiles('**/package-lock.json', '**/package.json') }}
key: node_modules-${{ hashFiles('package-lock.json') }}

- name: Install dependencies
if: steps.cache-dependencies.outputs.cache-hit != 'true'
Expand All @@ -57,20 +57,20 @@ jobs:
run: npm run validate

lint:
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
needs: [ validate ]
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 12
node-version: 16

- name: Cache dependencies
id: cache-dependencies
uses: actions/cache@v1
with:
path: node_modules
key: node_modules-${{ hashFiles('**/package-lock.json', '**/package.json') }}
key: node_modules-${{ hashFiles('package-lock.json') }}

- name: Install dependencies
if: steps.cache-dependencies.outputs.cache-hit != 'true'
Expand All @@ -80,20 +80,20 @@ jobs:
run: npm run lint

test:
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
needs: [ validate ]
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 12
node-version: 16

- name: Cache dependencies
id: cache-dependencies
uses: actions/cache@v1
with:
path: node_modules
key: node_modules-${{ hashFiles('**/package-lock.json', '**/package.json') }}
key: node_modules-${{ hashFiles('package-lock.json') }}

- name: Install dependencies
if: steps.cache-dependencies.outputs.cache-hit != 'true'
Expand Down
101 changes: 101 additions & 0 deletions .github/workflows/preview-validations.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: Preview validations

on:
push:
tags-ignore:
- '**'
branches:
- master
pull_request:
types:
- synchronize
- opened

jobs:
validate:
runs-on: ubuntu-latest
defaults:
run:
working-directory: preview
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 16

- name: Cache dependencies
id: cache-dependencies
uses: actions/cache@v1
with:
path: preview/node_modules
key: preview_node_modules-${{ hashFiles('package-lock.json') }}

- name: Install dependencies
if: steps.cache-dependencies.outputs.cache-hit != 'true'
run: npm ci

- name: Check compilation errors
run: npm run validate

lint:
needs: [ validate ]
runs-on: ubuntu-latest
defaults:
run:
working-directory: preview
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 16

- name: Cache dependencies
id: cache-dependencies
uses: actions/cache@v1
with:
path: preview/node_modules
key: preview_node_modules-${{ hashFiles('package-lock.json') }}

- name: Install dependencies
if: steps.cache-dependencies.outputs.cache-hit != 'true'
run: npm ci

- name: Check coding standard violations
run: npm run lint

test:
needs: [ lint ]
timeout-minutes: 60
runs-on: ubuntu-latest
defaults:
run:
working-directory: preview
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16

- name: Cache dependencies
id: cache-dependencies
uses: actions/cache@v1
with:
path: preview/node_modules
key: preview_node_modules-${{ hashFiles('package-lock.json') }}

- name: Install dependencies
if: steps.cache-dependencies.outputs.cache-hit != 'true'
run: npm ci

- name: Install Playwright Browsers
run: npx playwright install --with-deps

- name: Run Playwright test
run: npm run test

- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: preview/playwright-report/
retention-days: 30
13 changes: 0 additions & 13 deletions babel.config.js

This file was deleted.

2 changes: 1 addition & 1 deletion docs/evaluator.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ resolves to the evaluation result.

Here's a minimal example showing how evaluate an expression:

```js
```ts
croct.evaluator.evaluate('session is starting').then(console.log);
```
Loading

0 comments on commit fe4ab87

Please sign in to comment.