diff --git a/.dockerignore b/.dockerignore index 3ae4abc41..7618ef07d 100644 --- a/.dockerignore +++ b/.dockerignore @@ -5,10 +5,9 @@ dist static apps/server/client target -*.lock -*-lock.* *.log *.db +.git # ignore contents in excess directories, some are kept only so cargo # doesn't yell at me diff --git a/.github/actions/build-desktop/action.yml b/.github/actions/build-desktop/action.yml new file mode 100644 index 000000000..615d3cb8e --- /dev/null +++ b/.github/actions/build-desktop/action.yml @@ -0,0 +1,37 @@ +name: 'Build Stump desktop app' +description: 'Compile the Stump desktop app' + +inputs: + platform: + description: 'The plaform of the runner' + required: true + +runs: + using: composite + steps: + - name: Checkout project + uses: actions/checkout@v3 + + # - name: Configure environment + # run: | + # if [[ ${{ inputs.platform }} == 'linux' || ${{ inputs.platform }} == 'windows' ]]; then + # echo "RUN_SETUP=false" >> $GITHUB_ENV + # else + # echo "RUN_SETUP=true" >> $GITHUB_ENV + # fi + + - name: Setup rust + uses: ./.github/actions/setup-cargo + + - name: Generate Prisma client + uses: ./.github/actions/setup-prisma + + - name: Copy bundled web app + uses: actions/download-artifact@v3 + with: + name: webapp + path: ./apps/desktop/dist + + - name: Compile desktop app + shell: bash + run: cargo build --package stump_desktop --release diff --git a/.github/actions/build-docker/action.yml b/.github/actions/build-docker/action.yml new file mode 100644 index 000000000..a0728c16f --- /dev/null +++ b/.github/actions/build-docker/action.yml @@ -0,0 +1,97 @@ +name: 'Build docker image' +description: 'Build and load or push a tagged docker image for stump' + +inputs: + username: + description: 'Username for docker login' + required: true + password: + description: 'Token for docker login' + required: true + load: + description: 'Set output-type to docker' + default: true + push: + description: 'Set output-type to registry' + default: false + tags: + description: 'List of tags to assigned to the image' + default: 'nightly' + platforms: + description: 'List of platforms to build' + required: true + +runs: + using: composite + steps: + - name: Get commit short sha + run: echo "GIT_REV=$(git rev-parse --short "$GITHUB_SHA")" >> $GITHUB_ENV + shell: bash + + - name: Format tags + run: | + echo "TAGS=$(echo ${{ inputs.tags }} | sed -e 's/,/,aaronleopold\/stump:/g' | sed -e 's/^/aaronleopold\/stump:/')" >> $GITHUB_ENV + shell: bash + + - name: Setup rust + uses: ./.github/actions/setup-cargo + + - name: Generate Prisma client + uses: ./.github/actions/setup-prisma + + # TODO: uncomment once cache stuff is resolved... + # - name: Setup Docker layers cache + # uses: actions/cache@v3 + # with: + # path: /tmp/.buildx-cache + # key: ${{ runner.os }}-buildx-${{ github.sha }} + # restore-keys: | + # ${{ runner.os }}-buildx- + + # We only need QEMU when an arm* platform is targeted + - name: Check QEMU requirement + id: check-qemu + run: | + if [[ ${{ inputs.platforms }} == *"arm"* ]]; then + echo "SETUP_QEMU=1" >> $GITHUB_OUTPUT + else + echo "SETUP_QEMU=0" >> $GITHUB_OUTPUT + fi + shell: bash + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + if: ${{ steps.check-qemu.outputs.SETUP_QEMU == '1' }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ inputs.username }} + password: ${{ inputs.password }} + + - name: Run buildx build + uses: docker/build-push-action@v4 + with: + context: . + build-args: | + "GIT_REV=${{ env.GIT_REV }}" + file: scripts/release/Dockerfile + platforms: ${{ inputs.platforms }} + load: ${{ inputs.load }} + push: ${{ inputs.push }} + tags: ${{ env.TAGS }} + # TODO: uncomment once cache stuff is resolved... + # cache-from: type=local,src=/tmp/.buildx-cache + # cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + + # https://github.com/docker/build-push-action/issues/252 + # TODO: https://github.com/moby/buildkit/issues/1896 + # TODO: uncomment once cache stuff is resolved... + # - name: Move buildx cache + # run: | + # rm -rf /tmp/.buildx-cache + # mv /tmp/.buildx-cache-new /tmp/.buildx-cache + # shell: bash diff --git a/.github/actions/build-server/action.yml b/.github/actions/build-server/action.yml index d8d944b43..f8a96739a 100644 --- a/.github/actions/build-server/action.yml +++ b/.github/actions/build-server/action.yml @@ -1,9 +1,9 @@ -name: 'Compile rust' -description: 'Compile stump rust server' +name: 'Build Stump server' +description: 'Compile the Stump Rust server' inputs: platform: - description: 'runner plaform' + description: 'The plaform of the runner' required: true runs: @@ -12,21 +12,26 @@ runs: - name: Checkout project uses: actions/checkout@v3 + # - name: Configure environment + # run: | + # if [[ ${{ inputs.platform }} == 'linux' || ${{ inputs.platform }} == 'windows' ]]; then + # echo "RUN_SETUP=false" >> $GITHUB_ENV + # else + # echo "RUN_SETUP=true" >> $GITHUB_ENV + # fi + - name: Setup rust - uses: ./.github/actions/setup-system + uses: ./.github/actions/setup-cargo - name: Generate Prisma client uses: ./.github/actions/setup-prisma - - name: Download frontend + + - name: Copy bundled web app uses: actions/download-artifact@v3 with: - name: web + name: webapp path: ./apps/server/dist - - name: Copy web app to tauri - run: cp -r ./apps/server/dist apps/desktop/dist - shell: bash - - - name: Build server + - name: Compile server shell: bash - run: cargo build --release + run: cargo build --package stump_server --release diff --git a/.github/actions/build-web/action.yml b/.github/actions/build-web/action.yml index a72795a25..9a39f4517 100644 --- a/.github/actions/build-web/action.yml +++ b/.github/actions/build-web/action.yml @@ -1,14 +1,27 @@ -name: 'Build Web Application' -description: "Build web application and upload it's artifacts" +name: 'Compile Web Application' +description: 'Compile stump web' runs: - using: 'composite' + using: composite steps: - - name: Build - uses: ./.github/actions/compile-web + - name: Checkout project + uses: actions/checkout@v3 - - name: Upload + - name: Setup pnpm + uses: ./.github/actions/setup-pnpm + + - name: Install dependencies + shell: bash + run: pnpm install + working-directory: apps/web + + - name: Build app + shell: bash + run: pnpm run build + working-directory: apps/web + + - name: Upload bundle uses: ./.github/actions/upload-artifact with: - upload-name: web + upload-name: webapp upload-path: apps/web/dist diff --git a/.github/actions/compile-web/action.yml b/.github/actions/compile-web/action.yml deleted file mode 100644 index efcf33345..000000000 --- a/.github/actions/compile-web/action.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: 'Compile Web Application' -description: 'Compile stump web' - -runs: - using: composite - steps: - - name: Checkout project - uses: actions/checkout@v3 - - - uses: ./.github/actions/setup-pnpm - - - name: Install dependencies - shell: bash - run: pnpm install - working-directory: apps/web - - - name: Build app - shell: bash - run: pnpm run build - working-directory: apps/web diff --git a/.github/actions/setup-cargo/action.yml b/.github/actions/setup-cargo/action.yml index b67987b2e..84bf59567 100644 --- a/.github/actions/setup-cargo/action.yml +++ b/.github/actions/setup-cargo/action.yml @@ -4,7 +4,17 @@ description: 'Install system dependencies and setup cache' runs: using: 'composite' steps: + - name: Configure environment + run: | + if [[ ${{ runner.name }} == 'manjaro-az' || ${{ runner.os }} == 'Windows' ]]; then + echo "RUN_SETUP=false" >> $GITHUB_ENV + else + echo "RUN_SETUP=true" >> $GITHUB_ENV + fi + shell: bash + - name: System setup + if: ${{ env.RUN_SETUP == 'true' }} shell: bash run: CHECK_NODE=0 CHECK_CARGO=0 DEV_SETUP=0 ./scripts/system-setup.sh diff --git a/.github/actions/setup-prisma/action.yaml b/.github/actions/setup-prisma/action.yaml index 7e1470e33..1f9d7ded9 100644 --- a/.github/actions/setup-prisma/action.yaml +++ b/.github/actions/setup-prisma/action.yaml @@ -11,7 +11,7 @@ runs: key: ${{ runner.os }}-prisma-${{ hashFiles('**/schema.prisma') }} - name: Generate Prisma client - working-directory: core + # working-directory: core if: steps.cache-prisma.outputs.cache-hit != 'true' shell: bash - run: cargo run -p prisma --release -- generate + run: cargo prisma generate --schema=./core/prisma/schema.prisma diff --git a/.github/actions/upload-artifact/action.yml b/.github/actions/upload-artifact/action.yml index 1073af517..c7a0beb51 100644 --- a/.github/actions/upload-artifact/action.yml +++ b/.github/actions/upload-artifact/action.yml @@ -2,7 +2,6 @@ name: 'Upload Local' description: 'Upload artifact to local action' inputs: - # Upload upload-name: required: true description: 'Name of the upload' diff --git a/.github/workflows/build_nix.yml b/.github/workflows/build_nix.yml index f09910002..af420f537 100644 --- a/.github/workflows/build_nix.yml +++ b/.github/workflows/build_nix.yml @@ -1,4 +1,4 @@ -name: "Build legacy Nix package on Ubuntu" +name: 'Stump Nix CI' on: push: @@ -15,5 +15,5 @@ jobs: - uses: cachix/install-nix-action@v17 - name: test run: nix develop --command "pkg-config" "--libs" "--cflags" "gdk-3.0" "gdk-3.0 >= 3.22" - # - name: Building package + # - name: Building package # run: nix develop --command pnpm core run setup && cargo check diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 07fc8a2ae..24a022a70 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,4 +1,4 @@ -name: Stump-CI +name: 'Stump Checks CI' on: pull_request: @@ -6,12 +6,11 @@ on: branches: - main +# TODO: figure out how to use moon here. jobs: check-rust: name: Rust checks - runs-on: ubuntu-latest - # TODO: remove this once I have my own, hosted runner... - if: github.ref == 'refs/heads/main' + runs-on: [self-hosted] steps: - name: Checkout repository uses: actions/checkout@v3 @@ -26,52 +25,23 @@ jobs: run: | cargo fmt --all -- --check cargo clippy -- -D warnings - - name: Run tests - run: | - cargo integration-tests + # TODO: fix the tests, then uncomment this + # - name: Run tests + # run: | + # cargo integration-tests check-typescript: name: TypeScript checks - runs-on: ubuntu-latest + runs-on: [self-hosted] steps: - name: Checkout repository uses: actions/checkout@v3 - - name: Setup pnpm and typescript + - name: Setup PNPM and TypeScript uses: ./.github/actions/setup-pnpm - - name: lint + - name: Run TypeScript lints run: pnpm lint # - name: typecheck # run: pnpm moon run :typecheck - - # release: - # name: Release (${{ matrix.platform }}) - # runs-on: ${{ matrix.platform }} - # # Release only runs on push to main. TODO: can I make this trigger on tag? - # if: github.event_name != 'pull_request' - # strategy: - # fail-fast: true - # matrix: - # platform: [ubuntu-latest, macos-latest, windows-latest] - # steps: - # - name: Checkout repository - # uses: actions/checkout@v3 - - # - name: Install Rust - # uses: actions-rs/toolchain@v1 - # with: - # toolchain: stable - # profile: minimal - # override: true - # # TODO: clippy?? - # components: rustfmt, rust-src - - # # TODO: figure out caching for rust deps - - # - name: Generate Prisma client - # uses: ./.github/actions/generate-prisma-client - - # TODO: pnpm setup - # TODO: docker builds -> maybe this helps? https://github.com/devture/matrix-corporal/blob/master/.gitlab-ci.yml diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index d83a24d59..e49c7655c 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -1,24 +1,65 @@ -name: Stump-nightly - -# on: -# schedule: -# # * is a special character in YAML so you have to quote this string -# - cron: '0 1 * * *' -# workflow_dispatch: +name: 'Stump Nightly CI' on: pull_request: branches: - - 'nightly' + - develop + - main + push: + branches: + - develop + +# TODO: should I push nightly on main pushes? then on tag, an actual tagged release? + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }} jobs: + docker-build: + name: Build docker image + runs-on: [self-hosted] + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # On PRs, we will only load the image into docker for the quickest platform + # (i.e. linux/amd64). This is mostly a smoke test, just rather ignorant verification + # that the image can be built. On pushes, we will actually build and push for + # all supported platforms. + - name: Configure environment + run: | + echo "LOAD=${{ github.event_name == 'pull_request' }}" >> $GITHUB_ENV + echo "PUSH=${{ github.event_name == 'push' }}" >> $GITHUB_ENV + + if [[ ${{ github.event_name }} == 'pull_request' ]]; then + echo "PLATFORMS=${{ vars.SUPPORTED_PR_DOCKER_PLATFORMS }}" >> $GITHUB_ENV + else + echo "PLATFORMS=${{ vars.SUPPORTED_DOCKER_PLATFORMS }}" >> $GITHUB_ENV + fi + + - name: Setup and build docker image + uses: ./.github/actions/build-docker + with: + username: ${{ env.DOCKER_USERNAME }} + password: ${{ env.DOCKER_PASSWORD }} + tags: 'nightly' + load: ${{ env.LOAD }} + push: ${{ env.PUSH }} + platforms: ${{ env.PLATFORMS }} + + # TODO: build executables for apple(x86_64,darwin?),linux(x86_64,arm64?), and windows(x86_64) + # These should be uploaded to the nightly release as artifacts. Old artifacts should be deleted + # before uploading new ones. + build-web: - strategy: - fail-fast: true - matrix: - plaform: [ubuntu-20.04] - name: Build web application - runs-on: ${{ matrix.plaform }} + name: Bundle web app + runs-on: [self-hosted] + if: false # TODO: don't do that steps: - name: Checkout repository uses: actions/checkout@v3 @@ -29,17 +70,38 @@ jobs: - name: Upload web build uses: ./.github/actions/upload-artifact with: - upload-name: web + upload-name: webapp upload-path: apps/web/dist + build-linux-server: + name: Compile server app (self-hosted linux) + needs: build-web + runs-on: [self-hosted] + if: false # TODO: don't do that + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Build server + uses: ./.github/actions/build-server + with: + platform: 'linux' + + - name: Upload stump server + uses: ./.github/actions/upload-artifact + with: + upload-name: stump_server-linux + upload-path: target/release/stump_server + build-server: strategy: fail-fast: true matrix: - plaform: [ubuntu-20.04] # We should probably build for window and macos - name: Build server and desktop - runs-on: ${{ matrix.plaform }} + platform: [macos, windows] + name: Compile server app needs: build-web + runs-on: ${{ matrix.platform }} + if: false # TODO: don't do that steps: - name: Checkout repository uses: actions/checkout@v3 @@ -47,18 +109,64 @@ jobs: - name: Build server uses: ./.github/actions/build-server with: - platform: ${{ matrix.plaform }} + platform: ${{ matrix.platform }} - name: Upload stump server uses: ./.github/actions/upload-artifact with: - upload-name: stump_server + upload-name: stump_server-${{ matrix.platform }} upload-path: target/release/stump_server - - uses: tauri-apps/tauri-action@v0 + # build-linux-desktop: + # name: Compile desktop app (self-hosted linux) + # needs: build-web + # runs-on: [self-hosted] + # if: false # TODO: don't do that + # steps: + # - name: Checkout repository + # uses: actions/checkout@v3 - - name: Upload desktop - uses: ./.github/actions/upload-artifact + # - name: Build desktop + # uses: ./.github/actions/build-desktop + # with: + # platform: 'linux' + + # - name: Upload desktop + # uses: ./.github/actions/upload-artifact + # with: + # upload-name: stump-desktop-linux + # upload-path: target/release/bundle + + build-desktop: + strategy: + fail-fast: true + matrix: + platform: [macos, windows] + name: Compile desktop app + needs: build-web + runs-on: ${{ matrix.platform }} + if: false # TODO: don't do that + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Build desktop + uses: ./.github/actions/build-desktop with: - upload-name: stump-desktop - upload-path: target/release/bundle + platform: ${{ matrix.platform }} + + # https://github.com/tauri-apps/tauri-action + # - uses: tauri-apps/tauri-action@v0 + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # tagName: stump-desktop-v__VERSION__ # the action automatically replaces \_\_VERSION\_\_ with the app version + # releaseName: 'Stump Desktop v__VERSION__' + # releaseBody: 'See the assets to download this version and install.' + # releaseDraft: true + # prerelease: true + + # - name: Upload desktop + # uses: ./.github/actions/upload-artifact + # with: + # upload-name: stump-desktop-${{ matrix.platform }} + # upload-path: target/release/bundle diff --git a/.gitignore b/.gitignore index 6a933ccdd..f08f63794 100644 --- a/.gitignore +++ b/.gitignore @@ -18,7 +18,8 @@ logs/ build/ coverage/ cjs/ -dist/ +**/*/dist/**/* +!**/*/dist/.placeholder dts/ esm/ lib/ diff --git a/.vscode/.todo b/.vscode/.todo index ca4ef7813..ea96ecb86 100644 --- a/.vscode/.todo +++ b/.vscode/.todo @@ -76,3 +76,5 @@ - [ ] Make light mode look not disgusting lmao - [ ] ~Fix poor performance of EditLibraryModal~ - [ ] Just replace the modals with dedicated pages for editing and creating libraries +- [ ] `local-ip-address` check if release yoinked comes back okay +- [ ] cargo report future-incompatibilities --id 4 --package rustc-serialize@0.3.24 diff --git a/Cargo.lock b/Cargo.lock index 24f7a3bf4..4beb62177 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2544,8 +2544,7 @@ dependencies = [ [[package]] name = "local-ip-address" version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "faa9d02443a1741e9f51dafdfcbffb3863b2a89c457d762b40337d6c5153ef81" +source = "git+https://github.com/EstebanBorai/local-ip-address.git?tag=v0.5.1#efb3a0b074ea9540bb055f1fe8f0fc5a5591b6bf" dependencies = [ "libc", "neli", diff --git a/Cargo.toml b/Cargo.toml index ac2f92b77..37ed18db0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ members = [ [workspace.package] version = "0.0.0" -rust-version = "1.64.0" +rust-version = "1.68.0" [workspace.dependencies] prisma-client-rust = { git = "https://github.com/Brendonovich/prisma-client-rust.git", tag = "0.6.4", features = [ diff --git a/README.md b/README.md index f1b88fa2e..d5b3286a8 100644 --- a/README.md +++ b/README.md @@ -16,8 +16,8 @@ - - + +
@@ -37,7 +37,7 @@ Stump is a free and open source comics, manga and digital book server with OPDS - [Roadmap 🗺](#roadmap-) - [Getting Started 🚀](#getting-started-) - [Developer Guide 💻](#developer-guide-) - - [Where to start?](#where-to-start) + - [Where to start?](#where-to-start) - [Project Structure 📦](#project-structure-) - [/apps](#apps) - [/packages](#packages) @@ -80,7 +80,7 @@ I am very open to suggestions and ideas, so feel free to reach out if you have a Stump isn't ready for normal, non-development usage yet. Once a release has been made, this will be updated. For now, follow the [Developing](#developing-) section to build from source and run locally. -There is a [docker image](https://hub.docker.com/repository/docker/aaronleopold/stump-preview) available for those interested. However, **this is only meant for testing purposes and will not be updated frequently**, so do not expect a fully featured, bug-free experience if you spin up a container. Also keep in mind migrations won't be stacked until a release, so each update until then might require a wipe of the database file. +There is a [docker image](https://hub.docker.com/repository/docker/aaronleopold/stump) available for those interested. However, **this is only meant for testing purposes and will not be updated frequently**, so do not expect a fully featured, bug-free experience if you spin up a container. Also keep in mind migrations won't be stacked until a release, so each update until then might require a wipe of the database file. For more information about getting started, how Stump works and how it manages your library, and much more, please visit [stumpapp.dev](https://stumpapp.dev/guides). diff --git a/apps/server/Cargo.toml b/apps/server/Cargo.toml index 9d8a0e4ef..b5174a2e6 100644 --- a/apps/server/Cargo.toml +++ b/apps/server/Cargo.toml @@ -31,7 +31,10 @@ serde = { workspace = true } axum-sessions = "0.4.1" async-trait = "0.1.53" async-stream = { workspace = true } -local-ip-address = "0.5.1" +# TODO: figure out this super fucking annoying cargo dependency resolution issue. This is the second time +# cargo, in docker, has ignored the workspace version of this dep and instead used the latest version from crates.io +# local-ip-address = "0.5.1" +local-ip-address = { git = "https://github.com/EstebanBorai/local-ip-address.git", tag = "v0.5.1" } ### Dev Utils ### diff --git a/apps/server/src/routers/api/v1/log.rs b/apps/server/src/routers/api/v1/log.rs index b03997cfb..c516e2a0b 100644 --- a/apps/server/src/routers/api/v1/log.rs +++ b/apps/server/src/routers/api/v1/log.rs @@ -50,7 +50,6 @@ async fn get_logs() -> ApiResult<()> { )] /// Get information about the Stump log file, located at STUMP_CONFIG_DIR/Stump.log, or /// ~/.stump/Stump.log by default. Information such as the file size, last modified date, etc. -// #[get("/logs")] async fn get_logfile_info(session: ReadableSession) -> ApiResult