Skip to content

Commit

Permalink
Maintenance
Browse files Browse the repository at this point in the history
  • Loading branch information
vslinko committed May 4, 2023
1 parent 8797eb1 commit 85399c7
Show file tree
Hide file tree
Showing 21 changed files with 1,253 additions and 732 deletions.
11 changes: 6 additions & 5 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ name: Bug report
about: Create a report to help us improve
title: "[BUG]"
labels: bug
assignees: ''
assignees: ""
---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
Expand All @@ -22,10 +23,10 @@ A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. MacOS]
- Obsidian Version: [e.g. 0.12.3]
- Plugin Version: [e.g. 0.1.0]
**Environment (please complete the following information):**
- OS: [e.g. Desktop, iOS, Android]
- Obsidian Version: [e.g. 1.1.16]
- Plugin Version: [e.g. 1.1.1]

**Additional context**
Add any other context about the problem here.
76 changes: 66 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,36 @@
name: Build

on:
pull_request:
push:
branches: "**"
branches:
- main
pull_request:
branches:
- main
release:
types:
- created

env:
OBSIDIAN_VERSION: "1.1.16"
OBSIDIAN_FLATPAK_COMMIT: f885ddeab17171e10486bce93b83e84494614cf654e8c70a237f5294b05b4c55

jobs:
build-linux:
lint:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18
- name: Install dependencies
run: npm ci
- name: Lint
run: |
npm run lint
test-on-linux:
runs-on: ubuntu-22.04
steps:
- name: Install Obsidian
Expand All @@ -28,17 +48,14 @@ jobs:
node-version: 18
- name: Install dependencies
run: npm ci
- name: Lint
run: |
npm run lint
- name: Test
run: |
npm run build-with-tests
Xvfb -ac :0 -screen 0 1280x1024x16 &
export DISPLAY=:0
export $(dbus-launch)
npm test
build-osx:
test-on-osx:
runs-on: macos-12
steps:
- name: Install Obsidian
Expand All @@ -55,10 +72,49 @@ jobs:
node-version: 18
- name: Install dependencies
run: npm ci
- name: Lint
run: |
npm run lint
- name: Test
run: |
npm run build-with-tests
npm test
release:
if: ${{ github.event_name == 'release' }}
runs-on: ubuntu-22.04
needs: [lint, test-on-linux, test-on-osx]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Upload main.js
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: main.js
asset_name: main.js
asset_content_type: text/javascript
- name: Upload manifest.json
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: manifest.json
asset_name: manifest.json
asset_content_type: application/json
- name: Upload styles.css
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: styles.css
asset_name: styles.css
asset_content_type: text/css
105 changes: 0 additions & 105 deletions .github/workflows/release.yml

This file was deleted.

8 changes: 7 additions & 1 deletion jest.config.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
{
"clearMocks": true,
"transform": {
"\\.ts$": "babel-jest",
"\\.spec\\.md$": "./jest/md-spec-transformer.js"
},
"testRegex": ["/__tests__/.*\\.ts$", "\\.spec\\.md$"],
"moduleFileExtensions": ["js", "ts", "md"],
"globalSetup": "./jest/global-setup.js",
"globalTeardown": "./jest/global-teardown.js",
"setupFilesAfterEnv": ["./jest/obsidian-expect.js"],
"testEnvironment": "node",
"testEnvironment": "./jest/obsidian-environment.js",
"maxConcurrency": 1,
"maxWorkers": 1
}
16 changes: 15 additions & 1 deletion jest/global-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,26 +177,40 @@ module.exports = async () => {
debug(`Obsidian exited with code ${code}`);
});

debug("Waiting for Obsidian WebSocket connection");
const obsidianWs = await new Promise((resolve) => {
wss.once("connection", (ws) => {
resolve(ws);
debug("Waiting for Obsidian ready message");
ws.once("message", (msg) => {
if (msg.toString() === "ready") {
resolve(ws);
}
});
});
});
debug("Obsidian WebSocket ready");

const callbacks = new Map();

obsidianWs.on("message", (message) => {
const { id, data, error } = JSON.parse(message);
debug(`Response from Obsidian ${id}`);
const cb = callbacks.get(id);
if (cb) {
callbacks.delete(id);
cb(error, data);
} else {
debug(`Callback not found for ${id}`);
process.exit(1);
}
});

debug("Waiting for test environment connection");
wss.on("connection", (ws) => {
debug("Test environment connected");
ws.on("message", (message) => {
const { id, type, data } = JSON.parse(message);
debug(`Request to Obsidian ${type} ${id}`);
callbacks.set(id, (error, data) => {
ws.send(JSON.stringify({ id, error, data }));
});
Expand Down
Loading

0 comments on commit 85399c7

Please sign in to comment.