Skip to content

Add up-down experiment #1650

Add up-down experiment

Add up-down experiment #1650

Workflow file for this run

name: Web-client tests
on:
pull_request:
branches:
- main
paths:
- "packages/web-client/**"
- ".github/workflows/webclient-deploy.yml"
- ".github/workflows/webclient-setup/action.yml"
- ".github/workflows/webclient-test.yml"
- ".github/workflows/webclient-test-deploy.yml"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
issues: write
pull-requests: write
jobs:
svelte-check:
if: github.event.pull_request.draft == false
timeout-minutes: 2
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
cache: "npm"
- name: Install dependencies & build
run: npm i
- name: Run sync
run: npm run wc:sync
- name: Run svelte-check
run: npm run wc:check
deploy-preview:
needs: ["svelte-check"]
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
outputs:
previewUrl: ${{ steps.preview-url.outputs.url }}
steps:
- uses: actions/checkout@v3
with:
submodules: "true"
- name: Set-up env
uses: ./.github/workflows/webclient-setup
- run: npm run wc:build
- name: Deploy preview build
uses: cloudflare/[email protected]
with:
apiToken: ${{ secrets.CLOUDFLARE_WORKERS_DEPLOY_API_TOKEN }}
workingDirectory: "packages/web-client/"
command: pages publish ".svelte-kit/cloudflare" --branch=${{ github.head_ref }} --project-name=hot-or-not-web-client --commit-dirty=true | tee url.txt
env:
CLOUDFLARE_ACCOUNT_ID: "a209c523d2d9646cc56227dbe6ce3ede"
- name: Get preview deployment URL
id: preview-url
working-directory: "packages/web-client/"
run: |
echo "url=$(grep -o 'http[s]*://[^\\]*' url.txt)" >> $GITHUB_OUTPUT
comment-on-pr:
name: Add a comment with the deployment link on the PR
if: github.actor != 'dependabot[bot]'
needs: ["deploy-preview"]
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v6
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Deployed on Cloudflare pages: ${{ needs.deploy-preview.outputs.previewUrl }}'
})
google-chat-webhook:
name: Send URL to Google chat workspace
if: github.actor != 'dependabot[bot]'
needs: ["deploy-preview"]
runs-on: ubuntu-latest
steps:
- name: Send deployment URL to Google Chat
uses: fjogeleit/[email protected]
with:
url: "https://chat.googleapis.com/v1/spaces/AAAAAfsrp8U/messages?key=AIzaSyDdI0hCZtE6vySjMm-WEfRq3CPzqKqqsHI&token=_QvV-c8ZdTVTzGZxXW_PdR_o-0HI8VhO3I9dMAp6zls%3D"
method: "POST"
customHeaders: '{"Content-Type": "application/json"}'
data: '{"text": "PR: \"${{ github.event.pull_request.title }}\" deployed at: \n ${{ needs.deploy-preview.outputs.previewUrl }}"}'
tests-lighthouse-reports:
needs: ["svelte-check"]
if: github.event.pull_request.draft == false
timeout-minutes: 40
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: "true"
- uses: actions/setup-node@v3
with:
node-version: 18
cache: "npm"
- name: Install dependencies
run: npm i
- name: Echo expression
run: echo ${{ (github.actor != 'dependabot[bot]' && 'wc:test:record') || 'wc:test' }}
- name: Add Rust wasm target
run: rustup target add wasm32-unknown-unknown
- name: Install DFX
run: DFX_VERSION=0.13.1 sh -ci "$(curl -fsSL https://smartcontracts.org/install.sh)"
- name: Cache rust dependencies, build output and DFX build cache
uses: actions/cache@v3
id: dfx-cache
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
./packages/hot-or-not-backend-canister/target/
./packages/hot-or-not-backend-canister/.dfx/
key: ${{ runner.os }}-testing-${{ hashFiles('**/Cargo.lock') }}
- name: Start DFX Server
if: always()
working-directory: ./packages/hot-or-not-backend-canister
run: dfx start --background
- name: Provision local canister IDs for the canisters
working-directory: ./packages/hot-or-not-backend-canister
run: |
dfx canister create --no-wallet configuration
dfx canister create --no-wallet individual_user_template
dfx canister create --no-wallet user_index
dfx canister create --no-wallet post_cache
- name: Install canisters
if: always()
working-directory: ./packages/hot-or-not-backend-canister
run: ./scripts/canisters/local_deploy/install_all_canisters.sh -si
- name: Test DFX connection
if: always()
run: dfx ping http://localhost:4943
# - name: Run vitest
# run: |
# set -euxo pipefail
# npm run wc:test:vi
- name: Set-up env
uses: ./.github/workflows/webclient-setup
- name: Run Cypress tests
uses: cypress-io/github-action@v5
with:
browser: chrome
project: ./packages/web-client
build: npm run wc:build
start: npm run wc:preview
command: npm run ${{ (github.actor != 'dependabot[bot]' && 'wc:test:record') || 'wc:test' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
CYPRESS_PROJECT_ID: uv7vm5
TEST_HOST: http://localhost:4173
- name: Lighthouse CI check
run: |
npm run wc:build
npm install -g @lhci/cli
lhci_host=http://localhost:4174 lhci autorun
env:
LHCI_GITHUB_APP_TOKEN: ${{ secrets.LHCI_GITHUB_APP_TOKEN }}
- name: Stop DFX Server
run: dfx stop
if: always()
- uses: actions/upload-artifact@v3
if: always()
with:
name: lighthouse-ci-report
path: lhci_report
retention-days: 7
- uses: actions/upload-artifact@v3
if: always()
with:
name: coverage-report
path: packages/web-client/coverage/
retention-days: 7
- uses: actions/upload-artifact@v3
if: always()
with:
name: cypress-report
path: packages/web-client/cypress/
retention-days: 7
- uses: actions/upload-artifact@v3
if: always()
with:
name: cypress-report
path: packages/web-client/cypress/reports/mochawesome-report
retention-days: 7