diff options
Diffstat (limited to '.github')
-rw-r--r-- | .github/ISSUE_TEMPLATE/bug_report.yml | 61 | ||||
-rw-r--r-- | .github/ISSUE_TEMPLATE/config.yml | 13 | ||||
-rw-r--r-- | .github/actions/publish-artifacts/.gitignore | 2 | ||||
-rw-r--r-- | .github/actions/publish-artifacts/action.yaml | 14 | ||||
-rw-r--r-- | .github/actions/publish-artifacts/index.ts | 101 | ||||
-rw-r--r-- | .github/actions/publish-artifacts/package.json | 17 | ||||
-rw-r--r-- | .github/actions/publish-artifacts/tsconfig.json | 11 | ||||
-rw-r--r-- | .github/actions/setup-pnpm/action.yml | 28 | ||||
-rw-r--r-- | .github/actions/setup-rust/action.yaml | 52 | ||||
-rw-r--r-- | .github/actions/setup-system/action.yml | 36 | ||||
-rw-r--r-- | .github/scripts/setup.ps1 | 0 | ||||
-rw-r--r-- | .github/scripts/setup.sh | 0 | ||||
-rw-r--r-- | .github/workflows/cache-factory.yaml | 77 | ||||
-rw-r--r-- | .github/workflows/release.yaml | 102 | ||||
-rw-r--r-- | .github/workflows/testing.yaml | 142 |
15 files changed, 656 insertions, 0 deletions
diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 0000000..31ba093 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,61 @@ +name: 🐞 Bug Report +description: Report a bug +labels: + - kind/bug + - status/needs-triage + +body: + - type: checkboxes + id: product + attributes: + label: Product name + description: What Polyfrost product are you using? + options: + - label: Website + - label: Launcher + - label: Installer + + - type: markdown + attributes: + value: | + ## First of all + 1. Please search for [existing issues](https://github.com/polyfrost/nexus/issues?q=is%3Aissue) about this problem first. + 2. Make sure it's an issue with our products and not something else you are using. + 3. Remember to follow our community guidelines and be friendly. + + - type: textarea + id: description + attributes: + label: Describe the bug + description: A clear description of what the bug is. Include screenshots if applicable. + placeholder: Bug description + validations: + required: true + + - type: textarea + id: reproduction + attributes: + label: Reproduction + description: Steps to reproduce the behavior. + placeholder: | + 1. Go to ... + 2. Click on ... + 3. See error + + - type: textarea + id: expected-behavior + attributes: + label: Expected behavior + description: A clear description of what you expected to happen. + + - type: textarea + id: logs + attributes: + label: Stack trace (optional) + render: Shell + + - type: textarea + id: context + attributes: + label: Additional context + description: Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..77fbf47 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,13 @@ +# tell yaml plugin that this is the config file and not a template of its own: +# yaml-language-server: $schema=https://json.schemastore.org/github-issue-config.json +blank_issues_enabled: false +contact_links: + - name: 🙏 Get Help + url: https://github.com/polyfrost/nexus/discussions/new?category=help + about: If you can't get something to work the way you expect, open a question in our discussion forums. + - name: 💡 Feature Request + url: https://github.com/polyfrost/nexus/discussions/new?category=ideas + about: Suggest any ideas you have using our discussion forums. + - name: 💬 Discord Chat + url: https://polyfrost.cc/discord + about: Ask questions and talk to other Polyfrost product users and the devs. diff --git a/.github/actions/publish-artifacts/.gitignore b/.github/actions/publish-artifacts/.gitignore new file mode 100644 index 0000000..5c4b4fd --- /dev/null +++ b/.github/actions/publish-artifacts/.gitignore @@ -0,0 +1,2 @@ +# pls tell me there is a better way +!dist diff --git a/.github/actions/publish-artifacts/action.yaml b/.github/actions/publish-artifacts/action.yaml new file mode 100644 index 0000000..c3679af --- /dev/null +++ b/.github/actions/publish-artifacts/action.yaml @@ -0,0 +1,14 @@ +name: Publish artifacts +description: Publishes artifacts after CI process +inputs: + target: + description: target triples for built artifact + profile: + description: "'debug' or 'release'" + os: + description: "'darwin', 'windows', or 'linux'" + arch: + description: "'x86_64' or 'aarch64'" +runs: + using: node20 + main: dist/index.js diff --git a/.github/actions/publish-artifacts/index.ts b/.github/actions/publish-artifacts/index.ts new file mode 100644 index 0000000..8509194 --- /dev/null +++ b/.github/actions/publish-artifacts/index.ts @@ -0,0 +1,101 @@ +import * as artifact from '@actions/artifact'; +import * as core from '@actions/core'; +import * as glob from '@actions/glob'; +import * as io from '@actions/io'; + +// script to build tauri bundles without pain + +type OS = 'darwin' | 'windows' | 'linux'; +type Arch = 'x64' | 'arm64'; // 'aarch64'; +// i could type this with tauri's config but idrc +type TargetConfig = { bundle: string; ext: string }; +type BuildTarget = { + updater: TargetConfig; + standalone: Array<TargetConfig>; +}; + +const OS_TARGETS = { + darwin: { + updater: { + bundle: 'macos', + ext: 'app.tar.gz' + }, + standalone: [{ ext: 'dmg', bundle: 'dmg' }] + }, + windows: { + updater: { + bundle: 'msi', + ext: 'msi.zip' + }, + standalone: [{ ext: 'msi', bundle: 'msi' }] + }, + linux: { + updater: { + bundle: 'appimage', + ext: 'AppImage.tar.gz' + }, + standalone: [ + { ext: 'deb', bundle: 'deb' }, + { ext: 'AppImage', bundle: 'appimage' } + ] + } +} satisfies Record<OS, BuildTarget>; + +const OS: OS = core.getInput('os') as any; +const ARCH: Arch = core.getInput('arch') as any; +const TARGET = core.getInput('target'); +const PROFILE = core.getInput('profile'); + +const BUNDLE_DIR = `target/${TARGET}/${PROFILE}/bundle`; +const ARTIFACTS_DIR = '.artifacts'; +const ARTIFACT_BASE = `Nexus-${OS}-${ARCH}`; +const UPDATER_ARTIFACT_NAME = `Nexus-Updater-${OS}-${ARCH}`; + +const client = artifact.create(); + +// globby glob globber :3 +const globFiles = async (pattern: string) => { + const globber = await glob.create(pattern); + return await globber.glob(); +}; + +const uploadUpdater = async ({ bundle, ext }: TargetConfig) => { + const files = await globFiles(`${BUNDLE_DIR}/${bundle}/*.${ext}*`); + const updaterPath = files.find((f) => f.endsWith(ext)); + + if (!updaterPath) return console.error(`updater path not found. ${files}`); + + const artifactPath = `${ARTIFACTS_DIR}/${UPDATER_ARTIFACT_NAME}.${ext}`; + + await io.cp(updaterPath, artifactPath); + await io.cp(`${updaterPath}.sig`, `${artifactPath}.sig`); + + await client.uploadArtifact( + UPDATER_ARTIFACT_NAME, + [artifactPath, `${artifactPath}.sig`], + ARTIFACTS_DIR + ); +}; + +const uploadStandalone = async ({ bundle, ext }: TargetConfig) => { + const files = await globFiles(`${BUNDLE_DIR}/${bundle}/*.${ext}*`); + const standalonePath = files.find((f) => f.endsWith(ext)); + + if (!standalonePath) return console.error(`standalone path not found. ${files}`); + + const artifactName = `${ARTIFACT_BASE}.${ext}`; + const artifactPath = `${ARTIFACTS_DIR}/${artifactName}`; + + await io.cp(standalonePath, artifactPath, { recursive: true }); + await client.uploadArtifact(artifactName, [artifactPath], ARTIFACTS_DIR); +}; + +const run = async () => { + await io.mkdirP(ARTIFACTS_DIR); + const { updater, standalone } = OS_TARGETS[OS]; + + await uploadUpdater(updater); + for (const f of standalone) await uploadStandalone(f); +}; + +run(); diff --git a/.github/actions/publish-artifacts/package.json b/.github/actions/publish-artifacts/package.json new file mode 100644 index 0000000..a02cff9 --- /dev/null +++ b/.github/actions/publish-artifacts/package.json @@ -0,0 +1,17 @@ +{ + "private": true, + "scripts": { + "_build_comment": "there has to be a better way to do this lol", + "build": "ncc build index.ts --minify" + }, + "dependencies": { + "@actions/artifact": "^1.1.2", + "@actions/core": "^1.10.1", + "@actions/github": "^6.0.0", + "@actions/glob": "^0.4.0", + "@actions/io": "^1.1.3" + }, + "devDependencies": { + "@vercel/ncc": "^0.38.0" + } +} diff --git a/.github/actions/publish-artifacts/tsconfig.json b/.github/actions/publish-artifacts/tsconfig.json new file mode 100644 index 0000000..8b4fecf --- /dev/null +++ b/.github/actions/publish-artifacts/tsconfig.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "target": "ES2015", + "module": "ESNext", + "moduleResolution": "Node", + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "strict": true, + "skipLibCheck": true + } +} diff --git a/.github/actions/setup-pnpm/action.yml b/.github/actions/setup-pnpm/action.yml new file mode 100644 index 0000000..97f462e --- /dev/null +++ b/.github/actions/setup-pnpm/action.yml @@ -0,0 +1,28 @@ +name: Setup Node.js, pnpm and dependencies +description: Setup Node.js, pnpm and dependencies +inputs: + token: + description: Github token + required: false + default: '' +runs: + using: 'composite' + steps: + - name: Install pnpm + uses: pnpm/action-setup@v2 + with: + version: 8.x.x + + - name: Install Node.js + uses: actions/setup-node@v3 + with: + token: ${{ inputs.token }} + check-latest: true + node-version-file: '.nvmrc' + + - name: Install pnpm deps + shell: ${{ runner.os == 'Windows' && 'powershell' || 'bash' }} + env: + NODE_ENV: debug + GITHUB_TOKEN: ${{ inputs.token }} + run: pnpm i --frozen-lockfile diff --git a/.github/actions/setup-rust/action.yaml b/.github/actions/setup-rust/action.yaml new file mode 100644 index 0000000..8cf9997 --- /dev/null +++ b/.github/actions/setup-rust/action.yaml @@ -0,0 +1,52 @@ +name: Setup Rust +description: Setup Rust +inputs: + target: + description: toolchain target triple + required: false + save-cache: + description: Whether to save the Rust cache + required: false + default: 'false' +runs: + using: 'composite' + steps: + - name: Install Rust + id: toolchain + uses: dtolnay/rust-toolchain@stable + with: + target: ${{ inputs.target }} + toolchain: stable + components: clippy, rustfmt + + - name: Cache Rust Dependencies + uses: Swatinem/rust-cache@v2 + with: + save-if: ${{ inputs.save-cache }} + prefix-key: 'v0-rust-deps' + shared-key: ${{ inputs.target }} + + - name: Cargo config.toml + shell: bash + run: echo '{}' | npx -y mustache - .cargo/config.toml.mustache .cargo/config.toml + + - name: Restore cached Prisma codegen + id: cache-prisma-restore + uses: actions/cache/restore@v3 + with: + key: prisma-1-${{ runner.os }}-${{ hashFiles('./core/prisma/*', './Cargo.toml') }} + path: crates/prisma/src/**/*.rs + + - name: Generate Prisma client + working-directory: core + if: ${{ steps.cache-prisma-restore.outputs.cache-hit != 'true' }} + shell: bash + run: cargo prisma generate + + - name: Save Prisma codegen + id: cache-prisma-save + if: ${{ inputs.save-cache == 'true' }} + uses: actions/cache/save@v3 + with: + key: ${{ steps.cache-prisma-restore.outputs.cache-primary-key }} + path: crates/prisma/src/**/*.rs diff --git a/.github/actions/setup-system/action.yml b/.github/actions/setup-system/action.yml new file mode 100644 index 0000000..3b33c82 --- /dev/null +++ b/.github/actions/setup-system/action.yml @@ -0,0 +1,36 @@ +name: Setup System and Rust +description: Setup System and Rust +inputs: + token: + description: Github token + required: false + default: '' + target: + description: toolchain target triple + required: false + setup-arg: + description: Argument for the system setup script + required: false + default: '' + save-cache: + description: Whether to save the System cache + required: false + default: 'false' +runs: + using: 'composite' + steps: + - name: Setup Rust and Dependencies + uses: ./.github/actions/setup-rust + with: + target: ${{ inputs.target }} + save-cache: ${{ inputs.save-cache }} + + - name: Run setup.sh script + shell: bash + if: ${{ runner.os == 'Linux' || runner.os == 'macOS' }} + run: ./.github/scripts/setup.sh ${{ inputs.setup-arg }} + + - name: Run setup.ps1 script + shell: powershell + if: ${{ runner.os == 'Windows' }} + run: ./.github/scripts/setup.ps1 diff --git a/.github/scripts/setup.ps1 b/.github/scripts/setup.ps1 new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/.github/scripts/setup.ps1 diff --git a/.github/scripts/setup.sh b/.github/scripts/setup.sh new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/.github/scripts/setup.sh diff --git a/.github/workflows/cache-factory.yaml b/.github/workflows/cache-factory.yaml new file mode 100644 index 0000000..d2535ab --- /dev/null +++ b/.github/workflows/cache-factory.yaml @@ -0,0 +1,77 @@ +# This workflow _produces_ caches which are used to speed up pull request builds. +# Originally from https://github.com/libp2p/rust-libp2p/blob/master/.github/workflows/cache-factory.yml + +name: Cache Factory + +on: + push: + paths: + - 'Cargo.lock' + - './scripts/setup.sh' + - './scripts/setup.ps1' + - '.github/workflows/cache-factory.yaml' + - '.github/actions/**/*.yml' + - '.github/actions/**/*.yaml' + - '**/build.rs' + - 'core/prisma/**' + branches: + - main + +# Cancel previous runs of the same workflow on the same branch. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + make_cache: + strategy: + fail-fast: true + matrix: + settings: + - host: macos-latest + target: x86_64-apple-darwin + - host: macos-latest + target: aarch64-apple-darwin + - host: windows-latest + target: x86_64-pc-windows-msvc + - host: ubuntu-20.04 + target: x86_64-unknown-linux-gnu + name: 'Make Cache' + runs-on: ${{ matrix.settings.host }} + steps: + - name: Maximize build space + if: ${{ runner.os == 'Linux' }} + uses: easimon/maximize-build-space@master + with: + swap-size-mb: 3072 + root-reserve-mb: 6144 + remove-dotnet: 'true' + remove-codeql: 'true' + remove-haskell: 'true' + remove-docker-images: 'true' + + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Symlink target to C:\ + if: ${{ runner.os == 'Windows' }} + shell: powershell + run: | + New-Item -ItemType Directory -Force -Path C:\nexus_target + New-Item -Path target -ItemType Junction -Value C:\nexus_target + + - name: Setup System and Rust + uses: ./.github/actions/setup-system + with: + token: ${{ secrets.GITHUB_TOKEN }} + target: ${{ matrix.settings.target }} + save-cache: 'true' + + - name: Clippy + run: cargo clippy --workspace --all-features --target ${{ matrix.settings.target }} + + - name: Compile (debug) + run: cargo test --workspace --all-features --no-run --target ${{ matrix.settings.target }} + + - name: Compile (release) + run: cargo test --workspace --all-features --no-run --release --target ${{ matrix.settings.target }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..4fbdbcd --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,102 @@ +name: Release + +on: + workflow_dispatch: + +# a lot of this isnt necessary but i'm designing ahead for tauri integration +jobs: + desktop-main: + strategy: + matrix: + settings: + - host: macos-latest + target: x86_64-apple-darwin + bundles: app,dmg + os: darwin + arch: x86_64 + - host: macos-latest + target: aarch64-apple-darwin + bundles: app,dmg + os: darwin + arch: aarch64 + - host: windows-latest + target: x86_64-pc-windows-msvc + bundles: msi + os: windows + arch: x86_64 + - host: ubuntu-20.04 + target: x86_64-unknown-linux-gnu + bundles: deb,appimage + os: linux + arch: x86_64 + name: Desktop - Main ${{ matrix.settings.target }} + runs-on: ${{ matrix.settings.host }} + steps: + - name: Maximize build space + if: ${{ runner.os == 'Linux' }} + uses: easimon/maximize-build-space@master + with: + swap-size-mb: 3072 + root-reserve-mb: 6144 + remove-dotnet: 'true' + remove-codeql: 'true' + remove-haskell: 'true' + remove-docker-images: 'true' + + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Symlink target to C:\ + if: ${{ runner.os == 'Windows' }} + shell: powershell + run: | + New-Item -ItemType Directory -Force -Path C:\nexus_target + New-Item -Path target -ItemType Junction -Value C:\nexus_target + + - name: Remove 32-bit libs + if: ${{ runner.os == 'Linux' }} + run: | + dpkg -l | grep i386 + sudo apt-get purge --allow-remove-essential libc6-i386 ".*:i386" + sudo dpkg --remove-architecture i386 + + - name: Setup System and Rust + uses: ./.github/actions/setup-system + with: + token: ${{ secrets.GITHUB_TOKEN }} + target: ${{ matrix.settings.target }} + + - name: Setup Node.js, pnpm and dependencies + uses: ./.github/actions/setup-pnpm + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Build + run: | + pnpm tauri build --ci -v --target ${{ matrix.settings.target }} --bundles ${{ matrix.settings.bundles }},updater + + # this doesnt work rn so just uhh dont use it lol + - name: Publish Artifacts + uses: ./.github/actions/publish-artifacts + with: + os: ${{ matrix.settings.os }} + arch: ${{ matrix.settings.arch }} + target: ${{ matrix.settings.target }} + profile: release + + release: + if: startsWith(github.ref, 'refs/tags/') + runs-on: ubuntu-latest + name: Create Release + needs: desktop-main + permissions: + contents: write + steps: + - name: Download artifacts + uses: actions/download-artifact@v3 + + - name: Create Release + uses: softprops/action-gh-release@v1 + with: + draft: true + files: '*/**' diff --git a/.github/workflows/testing.yaml b/.github/workflows/testing.yaml new file mode 100644 index 0000000..b92345c --- /dev/null +++ b/.github/workflows/testing.yaml @@ -0,0 +1,142 @@ +name: CI + +on: + pull_request: + merge_group: + +# Cancel previous runs of the same workflow on the same branch. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + typescript: + name: TypeScript + runs-on: ubuntu-20.04 + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Setup Node.js, pnpm and dependencies + uses: ./.github/actions/setup-pnpm + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Perform typechecks + run: pnpm typecheck + + eslint: + name: ESLint + runs-on: ubuntu-20.04 + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Setup Node.js, pnpm and dependencies + uses: ./.github/actions/setup-pnpm + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Perform linting + run: pnpm lint + + rustfmt: + name: Rust Formatting + runs-on: ubuntu-20.04 + steps: + - name: Maximize build space + if: ${{ runner.os == 'Linux' }} + uses: easimon/maximize-build-space@master + with: + swap-size-mb: 3072 + root-reserve-mb: 6144 + remove-dotnet: 'true' + remove-codeql: 'true' + remove-haskell: 'true' + remove-docker-images: 'true' + + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Symlink target to C:\ + if: ${{ runner.os == 'Windows' }} + shell: powershell + run: | + New-Item -ItemType Directory -Force -Path C:\nexus_target + New-Item -Path target -ItemType Junction -Value C:\nexus_target + + - uses: dorny/paths-filter@v2 + id: filter + with: + filters: | + changes: + - 'apps/cli/*/**' + - 'apps/desktop/crates/*/**' + - 'apps/desktop/src-tauri/*/**' + - 'core/**' + - 'crates/*/**' + - 'Cargo.toml' + - 'Cargo.lock' + + - name: Setup Rust + if: steps.filter.outputs.changes == 'true' + uses: ./.github/actions/setup-rust + + - name: Run rustfmt + if: steps.filter.outputs.changes == 'true' + run: cargo fmt --all -- --check + + clippy: + name: Clippy (${{ matrix.platform }}) + runs-on: ${{ matrix.platform }} + strategy: + matrix: + platform: [ubuntu-20.04, macos-latest, windows-latest] + steps: + - name: Maximize build space + if: ${{ runner.os == 'Linux' }} + uses: easimon/maximize-build-space@master + with: + swap-size-mb: 3072 + root-reserve-mb: 6144 + remove-dotnet: 'true' + remove-codeql: 'true' + remove-haskell: 'true' + remove-docker-images: 'true' + + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Symlink target to C:\ + if: ${{ runner.os == 'Windows' }} + shell: powershell + run: | + New-Item -ItemType Directory -Force -Path C:\nexus_target + New-Item -Path target -ItemType Junction -Value C:\nexus_target + + - uses: dorny/paths-filter@v2 + id: filter + with: + # this is also designing ahead for tauri + filters: | + changes: + - 'apps/cli/*/**' + - 'apps/desktop/crates/*/**' + - 'apps/desktop/src-tauri/*/**' + - 'core/**' + - 'crates/*/**' + - 'Cargo.toml' + - 'Cargo.lock' + + - name: Setup System and Rust + if: steps.filter.outputs.changes == 'true' + uses: ./.github/actions/setup-system + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Run Clippy + if: steps.filter.outputs.changes == 'true' + uses: actions-rs/clippy-check@v1 + with: + args: --workspace --all-features + token: ${{ secrets.GITHUB_TOKEN }} |