Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/actions/js-setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: 'JavaScript Setup'
description: 'Sets up the JS environment with Nix, Cachix, and cached dependencies'
inputs:
cache-playwright:
description: 'Whether to cache playwright browsers'
required: false
default: 'false'
outputs:
npm-cache-hit:
description: "Whether the npm cache was hit"
value: ${{ steps.npm-cache.outputs.cache-hit }}
playwright-cache-hit:
description: "Whether the Playwright cache was hit"
value: ${{ steps.playwright-cache.outputs.cache-hit }}
runs:
using: "composite"
steps:
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v4
- name: Use Cachix
uses: cachix/cachix-action@v12
with:
name: ping-sdk-samples
- name: Cache node_modules
uses: actions/cache@v4
id: npm-cache
with:
path: ./javascript/node_modules
key: ${{ runner.os }}-npm-${{ hashFiles('javascript/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-
- name: Cache Playwright browsers
if: inputs.cache-playwright == 'true'
uses: actions/cache@v4
id: playwright-cache
with:
path: |
~/.cache/ms-playwright
~/Library/Caches/ms-playwright
key: ${{ runner.os }}-playwright-${{ hashFiles('javascript/package-lock.json') }}
restore-keys: |
${{ runner.os }}-playwright-
82 changes: 48 additions & 34 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,57 +5,71 @@ on:
paths:
- 'javascript/**/*'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
pr:
lint:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
shardIndex: [1, 2, 3, 4] # Split tests into 4 shards
node: [18.19.0, 20.11.1]
runs-on: ${{ matrix.os }}
timeout-minutes: 10
defaults:
run:
working-directory: ./javascript
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- uses: actions/cache@v4
id: cache
with:
path: |
node_modules
key: ${{ runner.os }}-npm-${{matrix.node}}-${{ hashFiles('package-lock.json') }}

- run: npm ci
working-directory: ./javascript
if: steps.cache.outputs.cache-hit != 'true'
- uses: ./.github/actions/js-setup
id: setup

- name: Lint
run: npm run lint
- name: Install dependencies and Lint
run: |
nix develop --command bash -c "
set -e
if [ \"${{ steps.setup.outputs.npm-cache-hit }}\" != 'true' ]; then
npm ci
fi
npm run lint
"

- run: npx playwright install
e2e:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
shardIndex: [1, 2, 3, 4]
runs-on: ${{ matrix.os }}
timeout-minutes: 10
defaults:
run:
working-directory: ./javascript
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/js-setup
id: setup
with:
cache-playwright: 'true'

- name: E2E Tests - Shard ${{ matrix.shardIndex }} of 4
run: |
cd reactjs-todo && npm run e2e -- --shard=${{ matrix.shardIndex }}/4
cd ../reactjs-todo-davinci && npm run e2e -- --shard=${{ matrix.shardIndex }}/4
cd ../angular-todo && npm run e2e -- --shard=${{ matrix.shardIndex }}/4
cd ../angular-todo-davinci && npm run e2e -- --shard=${{ matrix.shardIndex }}/4
- name: Install Deps and Run E2E Tests
env:
REST_OAUTH_SECRET: ${{ secrets.REST_OAUTH_SECRET }}
run: |
nix develop --command bash -c "
set -e
if [ \"${{ steps.setup.outputs.npm-cache-hit }}\" != 'true' ]; then
npm ci
fi
if [ \"${{ steps.setup.outputs.playwright-cache-hit }}\" != 'true' ]; then
npx playwright install --with-deps
fi
npm run e2e -ws --if-present -- --shard=${{ matrix.shardIndex }}/4
"

- uses: actions/upload-artifact@v4
if: always()
with:
name: Playwright Results - ${{ runner.os }} - ${{ matrix.node }} - Shard ${{ matrix.shardIndex }} - ${{ github.run_attempt }}
name: Playwright Results - ${{ runner.os }} - Shard ${{ matrix.shardIndex }} - ${{ github.run_attempt }}
path: |
./javascript/reactjs-todo/test-results
./javascript/reactjs-todo/playwright-report
./javascript/angular-todo/test-results
./javascript/angular-todo/playwright-report
./javascript/reactjs-todo-davinci/test-results
./javascript/reactjs-todo-davinci/playwright-report
./javascript/angular-todo-davinci/test-results
./javascript/angular-todo-davinci/playwright-report
javascript/**/test-results/
javascript/**/playwright-report/
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,6 @@ code
terminalOutput
outputs/*
/.idea/
**/logs

.direnv/*
61 changes: 61 additions & 0 deletions javascript/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 57 additions & 0 deletions javascript/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
description = "A basic flake.nix for a Node.js project";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
flake-utils.url = "github:numtide/flake-utils";
};

outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
{
devShell = pkgs.mkShell {
buildInputs = with pkgs; [
nodejs
git
nodePackages.npm

# Add browser dependencies for Playwright
webkitgtk
gtk3
glib
xorg.libX11
xorg.libXcomposite
xorg.libXdamage
xorg.libXext
xorg.libXfixes
xorg.libXrandr
xorg.libxkbcommon
xorg.libxcb
xorg.libxshmfence
nss
alsa-lib
at-spi2-atk
cups
expat
libepoxy
libdrm
libgbm
libudev0-shim
libpulseaudio
libnotify
pango
];
shellHook = ''
if [ ! -d "node_modules" ]; then
echo "node_modules not found. Running npm install..."
npm install
fi
echo "Nix development shell is ready."
'';
};
}
);
}
Loading
Loading