Skip to content

Commit

Permalink
test: add initial setup for end-to-end testing
Browse files Browse the repository at this point in the history
includes a new GH Actions workflow that has the necessary
preparatory steps for e2e testing:

- install radicle-node and radicle-httpd
- create profile
- create test repo

following instructions from
https://code.visualstudio.com/api/working-with-extensions/testing-extension

Note: we are using the custom test runner, because this allows us to open VS Code
with the radicle repo we have previously created in the e2e tests

Signed-off-by: Yorgos Saslis <yorgo@protonmail.com>
  • Loading branch information
gsaslis committed Aug 8, 2024
1 parent 36d9a5f commit 84d3a5d
Show file tree
Hide file tree
Showing 8 changed files with 967 additions and 29 deletions.
6 changes: 0 additions & 6 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,3 @@ jobs:
run: pnpm run test:typings
- name: Test Unit
run: pnpm run test:unit
- name: Test E2E (Linux)
if: runner.os == 'Linux'
run: xvfb-run -a pnpm run test:e2e
- name: Test E2E (non-Linux)
if: runner.os != 'Linux'
run: pnpm run test:e2e
115 changes: 115 additions & 0 deletions .github/workflows/end-to-end-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: CI
on:
# TODO: when PR is ready to merge, we should adapt these depending on when we actually want this workflow to run
# push:
# branches: [ main ]
# pull_request:
# branches: [ main ]
push:
pull_request:

jobs:
e2e-test:
strategy:
matrix:
# TODO: when PR is ready to merge, we should adapt these depending on when we actually want this workflow to run
os: [macos-latest, ubuntu-latest, windows-latest]
# os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Install Radicle
env:
RAD_HOME: ${{ github.workspace }}/.radicle
run: |
echo "Installing radicle-node..."
curl -sSf https://radicle.xyz/install | sh
echo "Installing radicle-httpd..."
case "$(uname)/$(uname -m)" in
Darwin/arm64)
export TARGET="aarch64-apple-darwin" ;;
Darwin/x86_64)
export TARGET="x86_64-apple-darwin" ;;
Linux/arm64|Linux/aarch64)
export TARGET="aarch64-unknown-linux-musl" ;;
Linux/x86_64)
export TARGET="x86_64-unknown-linux-musl" ;;
*)
fatal "Your operating system is currently unsupported. Sorry!" ;;
esac
echo $TARGET
curl -s https://files.radicle.xyz/releases/radicle-httpd/0.11.0/radicle-httpd-0.11.0-$TARGET.tar.xz | tar -xJ --strip-components=2
mv radicle-httpd $RAD_HOME/bin/radicle-httpd
# add to path
echo "${RAD_HOME}/bin" >> $GITHUB_PATH
echo "RAD_HOME=${{ github.workspace }}/.radicle" >> $GITHUB_ENV
echo "RAD_PASSPHRASE=''" >> $GITHUB_ENV
- name: Create New Radicle Identity
run: |
rad auth --alias test_user
- name: Start Radicle Node and http API
run: |
rad node start &
echo "allowing node to start up..."
sleep 5
radicle-httpd --listen 0.0.0.0:8888 &
rad node status
rad self
- name: Create a new Radicle Repository
id: radicle-init
run: |
mkdir ${{ github.workspace }}/a_blog
cd ${{ github.workspace }}/a_blog
git config --global init.defaultBranch main
git init .
git config --local user.email "test@radicle.xyz"
git config --local user.name "Radicle Test"
echo "# A Blog" > README.md
git add README.md
git commit -m 'adds readme'
rad init --private --default-branch main --name "A_test_blog" --description "Some repo" --no-confirm --verbose
pwd
cd ..
chmod -R 777 a_blog
echo "RADICLE_REPO=${{ github.workspace }}/a_blog" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v4
with:
path: ${{ github.workspace }}/radicle-vscode-extension
- uses: pnpm/action-setup@v3
with:
version: 8
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: 'pnpm'
- name: Install Dependencies
working-directory: ${{ github.workspace }}/radicle-vscode-extension
run: npx npm-run-all -l verify-deps:*
- name: Compile
working-directory: ${{ github.workspace }}/radicle-vscode-extension
run: pnpm run pretest
- name: Test E2E (Linux)
working-directory: ${{ github.workspace }}/radicle-vscode-extension
if: runner.os == 'Linux'
env:
RAD_PATH: ${{ github.workspace }}/.radicle/bin/rad
run: |
echo "The repo is at: ${{ steps.radicle-init.outputs.radicle-repo }}"
xvfb-run -a pnpm run test:e2e
- name: Test E2E (non-Linux)
working-directory: ${{ github.workspace }}/radicle-vscode-extension
if: runner.os != 'Linux'
env:
RAD_PATH: ${{ github.workspace }}/.radicle/bin/rad
run: |
echo "The repo is at: ${{ steps.radicle-init.outputs.radicle-repo }}"
pnpm run test:e2e
16 changes: 16 additions & 0 deletions .vscode-test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { defineConfig } from '@vscode/test-cli';

// sample, from https://code.visualstudio.com/api/working-with-extensions/testing-extension
export default defineConfig([
{
label: 'endToEndTests',
files: 'dist/test/**/*.test.js',
// version: 'insiders',
workspaceFolder: './',
mocha: {
ui: 'tdd',
timeout: 20000
}
}
// you can specify additional test configurations, too
]);
9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,13 @@
"lint": "run-p lint:*",
"lint:extension": "eslint . --ext .vue,.ts,.tsx,.js,.jsx --max-warnings 0 --cache --cache-location node_modules/.cache/eslint",
"lint:webviews": "cd ./src/webviews && npm run lintfix",
"pretest": "tsc --sourceMap --project ./ ",
"test": "npm run test:typings && npm run test:unit && npm run test:e2e",
"test:typings": "run-p test:typings:*",
"test:typings:extension": "tsc --noEmit",
"test:typings:webviews": "cd ./src/webviews && npm run type-check",
"test:unit": "echo \"Unit testing not yet implemented.\"",
"test:e2e": "echo \"End-to-end testing not yet implemented.\""
"test:e2e": "node ./dist/test/runTest.js"
},
"main": "./dist/extension.js",
"activationEvents": [
Expand Down Expand Up @@ -579,15 +580,21 @@
"@antfu/eslint-config": "^0.39.8",
"@total-typescript/ts-reset": "^0.5.1",
"@types/javascript-time-ago": "^2.0.8",
"@types/glob": "^7.1.1",
"@types/lodash": "^4.17.6",
"@types/mocha": "^10.0.1",
"@types/node": "^20.11.21",
"@types/vscode": "^1.91.0",
"@vscode/test-cli": "^0.0.8",
"@vscode/test-electron": "^2.3.9",
"esbuild": "^0.23.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^8.10.0",
"eslint-plugin-prettier-vue": "^4.2.0",
"eslint-plugin-tailwindcss": "^3.14.3",
"eslint-plugin-vue-scoped-css": "^2.7.2",
"glob": "^7.1.4",
"mocha": "^10.2.0",
"npm-run-all": "^4.1.5",
"simple-git-hooks": "^2.9.0",
"ts-xor": "^1.3.0",
Expand Down
Loading

0 comments on commit 84d3a5d

Please sign in to comment.