Skip to content

Commit

Permalink
chore: enable nx cloud cache (#756)
Browse files Browse the repository at this point in the history
  • Loading branch information
nirgur authored Jul 24, 2024
1 parent 4b4d9bd commit f697e37
Show file tree
Hide file tree
Showing 5 changed files with 437 additions and 161 deletions.
91 changes: 49 additions & 42 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,74 +8,81 @@ env:
NODE_VERSION: 18.2
PNPM_VERSION: 8
jobs:
gitleaks:
name: 🔒 Run Git leaks
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
# Skip post-install scripts here, as a malicious
# script could steal NODE_AUTH_TOKEN.
- name: Install dependencies
run: pnpm install --frozen-lockfile --ignore-scripts
env:
CI: true
NODE_AUTH_TOKEN: ${{ secrets.CI_NPM_READ_ORG }}
- name: Gitleaks
run: npm run leaks
shell: bash
pr:
name: 👷 Build / Lint / Test
runs-on: ubuntu-latest
container:
# the container version should be the same as the version of the Playwright package
image: mcr.microsoft.com/playwright:v1.41.2-jammy
options: --user root
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
# ref: main
fetch-depth: 0
- uses: pnpm/action-setup@v4

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
- uses: actions/setup-node@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'pnpm'
- name: Restore cached npm dependencies
uses: actions/cache/restore@v4
with:
path: |
node_modules
key: npm-dependencies-${{ hashFiles('pnpm-lock.yaml') }}
# - name: Restore cached npm dependencies
# uses: actions/cache/restore@v4
# with:
# path: |
# node_modules
# key: npm-dependencies-${{ hashFiles('pnpm-lock.yaml') }}

# Setup container
- name: Mark directory as safe
run: git config --system --add safe.directory /__w/descope-js/descope-js
- name: Install jq
run: apt-get update && apt-get install -y jq
- name: Set permission
run: chmod -R 777 /usr/local

- name: Install dependencies
run: pnpm install --frozen-lockfile --ignore-scripts
env:
CI: true
NODE_AUTH_TOKEN: ${{ secrets.CI_NPM_READ_ORG }}
- name: Set NX cloud shas
uses: nrwl/nx-set-shas@v4
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Cache npm dependencies
uses: actions/cache/save@v4
with:
path: |
node_modules
key: npm-dependencies-${{ hashFiles('pnpm-lock.yaml') }}

# - name: Set NX cloud shas
# uses: nrwl/nx-set-shas@v4
# - name: Install Playwright Browsers
# run: npx playwright install --with-deps

# - name: Cache npm dependencies
# uses: actions/cache/save@v4
# with:
# path: |
# node_modules
# key: npm-dependencies-${{ hashFiles('pnpm-lock.yaml') }}

- name: Gitleaks
run: npm run leaks
shell: bash

- name: Build
run: pnpm run build
env:
NODE_AUTH_TOKEN: ${{ secrets.CI_NPM_READ_ORG }}

- name: Lint
run: pnpm run lint

- name: Test
run: pnpm run test

- name: E2E
run: pnpm nx affected --target test:e2e
env:
HOME: /root

- name: Upload HTML report
if: always()
uses: actions/upload-artifact@v4
Expand Down
59 changes: 43 additions & 16 deletions nx.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,57 @@
{
"$schema": "./node_modules/nx/schemas/nx-schema.json",
"npmScope": "descope",
"affected": { "defaultBase": "origin/main" },
"tasksRunnerOptions": {
"default": {
"runner": "nx/tasks-runners/default",
"options": { "cacheableOperations": ["build", "lint", "test", "e2e"] }
}
},
"defaultBase": "origin/main",
"targetDefaults": {
"build": {
"dependsOn": ["^build"],
"inputs": ["production", "^production"]
"dependsOn": [
"^build"
],
"inputs": [
"production",
"^production"
],
"cache": true
},
"lint": {
"dependsOn": ["^build"],
"dependsOn": [
"^build"
],
"inputs": [
"default",
"{workspaceRoot}/.eslintrc.json",
"{workspaceRoot}/.eslintignore"
]
],
"cache": true
},
"test": {
"inputs": ["default", "^production", "{workspaceRoot}/jest.preset.js"],
"dependsOn": ["^build"]
"inputs": [
"default",
"^production",
"{workspaceRoot}/jest.preset.js"
],
"dependsOn": [
"^build"
],
"cache": true
},
"test:e2e": {
"inputs": [
"default",
"^production",
"{projectRoot}/playwright.config.ts"
],
"dependsOn": [
"^build"
],
"cache": true
}
},
"namedInputs": {
"default": ["{projectRoot}/**/*", "sharedGlobals"],
"default": [
"{projectRoot}/**/*",
"sharedGlobals"
],
"production": [
"default",
"!{projectRoot}/.eslintrc.json",
Expand All @@ -37,6 +61,9 @@
],
"sharedGlobals": []
},
"workspaceLayout": { "appsDir": "packages/**", "libsDir": "packages/**" },
"nxCloudAccessToken": "OTk2MTNiMTQtODRiMi00OTVkLWE5MGQtNjMyY2ZkY2I0MDhlfHJlYWQtd3JpdGU="
"workspaceLayout": {
"appsDir": "packages/**",
"libsDir": "packages/**"
},
"nxCloudAccessToken": "OTk2MTNiMTQtODRiMi00OTVkLWE5MGQtNjMyY2ZkY2I0MDhlfHJlYWQtd3JpdGU=",
}
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"lint": "nx affected --target lint --fix=true",
"lint:ci": "pnpm affected:ci --target lint",
"test": "nx affected --target test",
"test:e2e": "nx affected --target test:e2e",
"print-affected": "nx print-affected --select=projects",
"affected:ci": "nx affected --base=$(sh ./tools/scripts/latestTag.sh)",
"preversion:ci": "sh ./tools/scripts/latestTag.sh",
Expand Down Expand Up @@ -45,8 +46,8 @@
"jest-environment-jsdom": "29.7.0",
"lint-staged": "^15.0.0",
"ngx-deploy-npm": "^8.0.0",
"nx": "19.3.2",
"playwright": "^1.41.2",
"nx": "19.5.2",
"playwright": "1.41.2",
"prettier": "^3.0.0",
"ts-jest": "29.1.5",
"ts-node": "10.9.2"
Expand Down
21 changes: 9 additions & 12 deletions packages/sdks/web-component/src/lib/helpers/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -493,18 +493,15 @@ export const showFirstScreenOnExecutionInit = (
oidcPrompt,
oidcErrorRedirectUri,
}: SSOQueryParams,
): boolean => {
return (
!!startScreenId &&
!oidcIdpStateId &&
!samlIdpStateId &&
!samlIdpUsername &&
!ssoAppId &&
!oidcLoginHint &&
!oidcPrompt &&
!oidcErrorRedirectUri
);
};
): boolean =>
!!startScreenId &&
!oidcIdpStateId &&
!samlIdpStateId &&
!samlIdpUsername &&
!ssoAppId &&
!oidcLoginHint &&
!oidcPrompt &&
!oidcErrorRedirectUri;

export const injectSamlIdpForm = (
url: string,
Expand Down
Loading

0 comments on commit f697e37

Please sign in to comment.