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
126 changes: 126 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
name: CI

on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

jobs:
# ─── Full Build (Java CSP + Component Plugin zip) ───────────────────
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17

- name: Cache Gradle packages
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('csp/**/*.gradle*', 'csp/gradle/wrapper/gradle-wrapper.properties') }}
restore-keys: ${{ runner.os }}-gradle-

- name: Run build.sh
run: |
chmod +x build.sh
./build.sh

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: build/

# ─── Java Lint (Checkstyle + SpotBugs + PMD) ────────────────────────
java-lint:
name: Java Lint
runs-on: ubuntu-latest
defaults:
run:
working-directory: csp
steps:
- uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17

- name: Cache Gradle packages
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('csp/**/*.gradle*', 'csp/gradle/wrapper/gradle-wrapper.properties') }}
restore-keys: ${{ runner.os }}-gradle-

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Checkstyle
run: ./gradlew checkstyleMain

- name: SpotBugs
run: ./gradlew spotbugsMain

- name: PMD
run: ./gradlew pmdMain

- name: Upload lint reports
uses: actions/upload-artifact@v4
if: always()
with:
name: java-lint-reports
path: |
csp/build/reports/checkstyle/
csp/build/reports/spotbugs/
csp/build/reports/pmd/

# ─── JavaScript Lint + Test + CVE ────────────────────────────────────
js:
name: JavaScript Lint & Test
runs-on: ubuntu-latest
defaults:
run:
working-directory: cp
steps:
- uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20

- name: Install dependencies
run: npm install

- name: ESLint
run: npx eslint 'richTextField/v1/index.js' 'richTextFieldWithTables/v1/index.js'

- name: Prettier check
run: npx prettier --config prettierrc.json --check 'richTextField/v1/index.js' 'richTextFieldWithTables/v1/index.js'

- name: Run tests
run: npx jest --coverage --ci

- name: npm audit
run: npm audit --audit-level=high
continue-on-error: true

- name: Upload coverage report
uses: actions/upload-artifact@v4
if: always()
with:
name: js-coverage
path: cp/coverage/
9 changes: 7 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,17 @@
/**/github-csp.properties

# Inclusions
!/**/.idea/gradle.xml
!/**/.idea/misc.xml
!/**/gradle/
!/**/gradle/wrapper/
!/**/gradle/wrapper/gradle-wrapper.jar
!/**/gradle/wrapper/gradle-wrapper.properties
!/**/.settings/
!/**/.settings/greclipse.properties
!/**/.settings/org.eclipse.jdt.core.prefs
!/**/.settings/org.eclipse.jdt.ui.prefs
!/**/.settings/org.eclipse.wst.xml.core.prefs
!/**/.idea/gradle.xml
!/**/.idea/misc.xml
!/**/.idea/eclipseCodeFormatter.xml

# Appian Plugins
Expand Down
62 changes: 62 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/env bash
set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
BUILD_DIR="$SCRIPT_DIR/build"

echo "=== Cleaning build directory ==="
rm -rf "$BUILD_DIR"
mkdir -p "$BUILD_DIR"

# ─── Build Java CSP ──────────────────────────────────────────────────
# Uses java.toolchain in build.gradle to auto-provision JDK 17 for compilation
# while cross-compiling to Java 8 bytecode (options.release = 8)

echo ""
echo "=== Building Java Connected System Plugin (csp) ==="
cd "$SCRIPT_DIR/csp"
chmod +x gradlew
./gradlew clean build -x spotbugsMain -x spotbugsTest

# Copy the built jar to the build directory
CSP_JAR=$(find build/libs -name '*.jar' -not -name '*-sources.jar' | head -1)
if [ -z "$CSP_JAR" ]; then
echo "ERROR: No JAR found in csp/build/libs/"
exit 1
fi
cp "$CSP_JAR" "$BUILD_DIR/"
echo " -> $(basename "$CSP_JAR") copied to build/"

# ─── Build Component Plugin (cp) ─────────────────────────────────────

echo ""
echo "=== Building Component Plugin (cp) ==="
cd "$SCRIPT_DIR/cp"

# Read version from appian-component-plugin.xml
VERSION=$(grep '<version>' appian-component-plugin.xml | head -1 | sed 's/.*<version>\(.*\)<\/version>.*/\1/')
ZIP_NAME="ComponentPlugin_Rich_Text_v${VERSION}.zip"

echo " Version: $VERSION"

# Create a temp staging directory
STAGING_DIR=$(mktemp -d)
trap "rm -rf $STAGING_DIR" EXIT

# Copy only the runtime files that belong in the plugin zip
cp appian-component-plugin.xml "$STAGING_DIR/"
rsync -a --exclude='.DS_Store' richTextField/ "$STAGING_DIR/richTextField/"
rsync -a --exclude='.DS_Store' richTextFieldWithTables/ "$STAGING_DIR/richTextFieldWithTables/"

# Create the zip
cd "$STAGING_DIR"
zip -r "$BUILD_DIR/$ZIP_NAME" . -x '*.DS_Store'

echo " -> $ZIP_NAME created in build/"

# ─── Summary ─────────────────────────────────────────────────────────

echo ""
echo "=== Build complete ==="
echo "Artifacts in $BUILD_DIR/:"
ls -lh "$BUILD_DIR/"
27 changes: 27 additions & 0 deletions cp/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"env": {
"browser": true,
"es6": true,
"jquery": true
},
"globals": {
"Appian": "readonly",
"Quill": "readonly",
"$": "readonly",
"english_translations": "readonly",
"french_translations": "readonly"
},
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "script"
},
"rules": {
"no-undef": "warn",
"no-unused-vars": ["warn", { "args": "none" }],
"no-redeclare": "warn",
"eqeqeq": ["warn", "smart"],
"no-eval": "error",
"no-implied-eval": "error",
"no-new-func": "error"
}
}
4 changes: 3 additions & 1 deletion cp/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
*.zip
**/.DS_Store
.componentTester
**/node_modules
**/node_modules
coverage
package-lock.json
19 changes: 19 additions & 0 deletions cp/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports = {
testEnvironment: "jsdom",
testMatch: ["**/tests/**/*.test.js"],
setupFiles: ["./tests/helpers/setupGlobals.js"],
transform: {
// Use our custom transform for the source index.js files
"richTextField/v1/index\\.js$": "./tests/helpers/browserScriptTransform.js",
"richTextFieldWithTables/v1/index\\.js$":
"./tests/helpers/browserScriptTransform.js",
},
// Don't transform node_modules, but DO transform our source files
transformIgnorePatterns: ["/node_modules/"],
collectCoverageFrom: [
"richTextField/v1/index.js",
"richTextFieldWithTables/v1/index.js",
],
coverageDirectory: "coverage",
coverageReporters: ["text", "lcov", "clover"],
};
20 changes: 20 additions & 0 deletions cp/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "appian-rich-text-component-plugin",
"version": "1.17.2",
"private": true,
"description": "Appian Rich Text Editor Component Plugin",
"scripts": {
"test": "jest --coverage",
"test:watch": "jest --watch",
"lint": "eslint 'richTextField/v1/index.js' 'richTextFieldWithTables/v1/index.js'",
"format": "prettier --config prettierrc.json --write 'richTextField/v1/index.js' 'richTextFieldWithTables/v1/index.js'",
"format:check": "prettier --config prettierrc.json --check 'richTextField/v1/index.js' 'richTextFieldWithTables/v1/index.js'"
},
"devDependencies": {
"eslint": "8.57.1",
"@eslint/js": "8.57.1",
"prettier": "3.3.3",
"jest": "29.7.0",
"jest-environment-jsdom": "29.7.0"
}
}
1 change: 0 additions & 1 deletion cp/prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
"singleQuote": false,
"tabWidth": 2,
"trailingComma": "es5",
"useEditorConfig": false,
"useTabs": false
}
Loading
Loading