Skip to content
Merged
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
181 changes: 12 additions & 169 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,179 +1,22 @@
name: CI/CD

permissions:
contents: read
contents: write
issues: write
pull-requests: write

on:
push:
branches:
- main
- master
- '**'
branches: [main, master, '**']
pull_request:
types: [opened, synchronize, reopened]
branches:
- main
- master

jobs:
filter:
name: Check for Code Changes
runs-on: ubuntu-latest
outputs:
code: ${{ steps.filter.outputs.code }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
code:
- 'src/**'
- 'package.json'
- 'package-lock.json'
- 'tsconfig.json'
- 'esbuild.config.mjs'
- 'eslint.config.mts'
- 'vitest.config.ts'
- 'styles.css'
- 'main.js'

lint:
name: Lint
needs: filter
if: needs.filter.outputs.code == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: '22'
cache: 'npm'
- run: npm ci
- run: npm run lint

test:
name: Test
needs: filter
if: needs.filter.outputs.code == 'true'
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: '22'
cache: 'npm'
- run: npm ci
- run: npm run test -- --coverage
- id: version
run: echo "version=$(node -p "require('./manifest.json').version")" >> $GITHUB_OUTPUT
- name: Upload coverage
uses: actions/upload-artifact@v7
with:
name: coverage-report
path: coverage/

sonar:
name: SonarQube
needs: [filter, test]
if: (needs.filter.outputs.code == 'true') && (github.event_name == 'pull_request' || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Download coverage
uses: actions/download-artifact@v8
with:
name: coverage-report
path: coverage/
- name: SonarQube Scan
uses: SonarSource/sonarqube-scan-action@v7.1.0
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: https://sonarcloud.io
with:
args: >
-Dsonar.qualitygate.wait=true
-Dsonar.scanner.dumpToFile=sonar-project.properties
- name: Upload Sonar logs
if: always()
uses: actions/upload-artifact@v7
with:
name: sonar-scan-logs
path: |
.scannerwork/
sonar-project.properties

artifact:
name: Package Artifact
runs-on: ubuntu-latest
permissions:
contents: read
needs: [filter, test]
# Run on PRs or feature branches if code changed
if: needs.filter.outputs.code == 'true' && (github.event_name == 'pull_request' || (github.ref != 'refs/heads/main' && github.ref != 'refs/heads/master'))
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: '22'
cache: 'npm'
- run: npm ci
- run: npm run build
- name: Create plugin package
run: |
VERSION=${{ needs.test.outputs.version }}
BRANCH_NAME=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}
BRANCH_NAME_SAFE=$(echo "$BRANCH_NAME" | sed 's/[^a-zA-Z0-9._-]/-/g')
ZIP_NAME="git-files-sync-${VERSION}-${BRANCH_NAME_SAFE}.zip"
zip -j "$ZIP_NAME" main.js manifest.json styles.css
echo "ZIP_NAME=$ZIP_NAME" >> $GITHUB_ENV
- uses: actions/upload-artifact@v7
with:
name: plugin-build-${{ needs.test.outputs.version }}-${{ github.sha }}
path: ${{ env.ZIP_NAME }}
retention-days: 7

release:
name: Build and Release
runs-on: ubuntu-latest
needs: [filter, lint, test, sonar]
# Only run on push to main/master if code changed
if: needs.filter.outputs.code == 'true' && github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
permissions:
contents: write
issues: write
pull-requests: write
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
persist-credentials: false
- uses: actions/setup-node@v6
with:
node-version: '22'
cache: 'npm'
- run: npm ci
- run: npm run build
- env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN || secrets.GITHUB_TOKEN }}
run: npx semantic-release

status:
name: CI/CD Status
runs-on: ubuntu-latest
if: always()
needs: [filter, lint, test, sonar, artifact, release]
steps:
- name: Check for failures
if: |
contains(needs.*.result, 'failure') ||
contains(needs.*.result, 'cancelled') ||
(needs.filter.result == 'skipped')
run: exit 1
- name: Success
run: echo "All required checks passed or were appropriately skipped"
CI:
uses: firstsun-dev/general-workflows/.github/workflows/obsidian-plugin-ci.yml@main
with:
plugin-id: "git-file-sync"
skip-sonar: false
secrets:
RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
2 changes: 1 addition & 1 deletion .releaserc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"branches": ["main", "master"],
"branches": ["main", "master", "feat/use-shared-workflow"],

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Including a specific feature branch (feat/use-shared-workflow) in the branches array will cause semantic-release to attempt a release from this branch. Typically, this configuration should only include stable branches (e.g., main, master) or designated pre-release branches. If this was added only for testing the CI changes, it should be removed before merging to avoid accidental releases or configuration clutter.

Suggested change
"branches": ["main", "master", "feat/use-shared-workflow"],
"branches": ["main", "master"],

"tagFormat": "${version}",
"plugins": [
[
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,4 @@
"obsidian": "latest"
}
}

2 changes: 1 addition & 1 deletion versions.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"1.0.0": "0.15.0", "1.1.0": "0.15.0"}
{"1.0.0": "0.15.0", "1.1.0": "1.12.7"}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

There is a version mismatch between the obsidian dependency (1.12.3 in package-lock.json) and the minAppVersion (1.12.7) specified here for version 1.1.0. This inconsistency may unnecessarily restrict users on Obsidian versions between 1.12.3 and 1.12.6. Unless 1.12.7 is specifically required for a bug fix or feature not present in 1.12.3, these versions should be aligned to ensure the widest possible compatibility for the targeted API version.

Suggested change
{"1.0.0": "0.15.0", "1.1.0": "1.12.7"}
{"1.0.0": "0.15.0", "1.1.0": "1.12.3"}

Loading