Merge branch 'PrismLauncher:main' into fix/new-support-channels

This commit is contained in:
KTrain 2024-11-24 21:45:01 +10:00 committed by GitHub
commit e9a1182914
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
28 changed files with 1285 additions and 712 deletions

View file

@ -1,66 +0,0 @@
name: Check
on:
push:
branches: ['main']
pull_request:
jobs:
rustfmt:
name: Run rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: rustfmt
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
- name: Run rustfmt
run: cargo fmt --all -- --check
clippy:
name: Run Clippy scan
runs-on: ubuntu-latest
permissions:
security-events: write
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: clippy
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
- name: Install SARIF tools
run: cargo install clippy-sarif sarif-fmt
- name: Fetch Cargo deps
run: cargo fetch --locked
- name: Run Clippy
continue-on-error: true
run: |
cargo clippy \
--all-features \
--all-targets \
--message-format=json \
| clippy-sarif | tee /tmp/clippy.sarif | sarif-fmt
- name: Upload results
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: /tmp/clippy.sarif
wait-for-processing: true

79
.github/workflows/ci.yml vendored Normal file
View file

@ -0,0 +1,79 @@
name: CI
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
jobs:
build:
name: Build (${{ matrix.os }})
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
use-nix: true
- os: windows-latest
use-nix: false
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust
if: ${{ !matrix.use-nix }}
uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Install Nix
if: ${{ matrix.use-nix }}
uses: DeterminateSystems/nix-installer-action@v16
- name: Setup Nix cache
if: ${{ matrix.use-nix }}
uses: DeterminateSystems/magic-nix-cache-action@v8
- name: Build
if: ${{ !matrix.use-nix }}
run: cargo build --locked
- name: Build
if: ${{ matrix.use-nix }}
run: nix build --print-build-logs .#refraction-debug
flake:
name: Flake checks
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v16
- name: Setup Nix cache
uses: DeterminateSystems/magic-nix-cache-action@v8
- name: Run checks
run: |
nix flake check --print-build-logs --show-trace
# Make sure all above jobs finished successfully
release-gate:
name: CI Release gate
needs: [build, flake]
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- name: Exit with error
if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
run: exit 1

47
.github/workflows/clippy.yml vendored Normal file
View file

@ -0,0 +1,47 @@
name: Clippy
on:
push:
branches: [main]
paths:
- 'Cargo.toml'
- 'Cargo.lock'
- '**.rs'
pull_request:
paths:
- 'Cargo.toml'
- 'Cargo.lock'
- '**.rs'
workflow_dispatch:
jobs:
clippy:
name: Run scan
runs-on: ubuntu-latest
permissions:
security-events: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v16
- name: Setup Nix cache
uses: DeterminateSystems/magic-nix-cache-action@v8
- name: Generate sarif report
id: clippy-run
run: |
nix build --print-build-logs .#clippy-report
[ -L result ] || exit 1
echo "sarif-file=$(readlink -f result)" >> "$GITHUB_OUTPUT"
- name: Upload results
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: ${{ steps.clippy-run.outputs.sarif-file }}
wait-for-processing: true

View file

@ -2,27 +2,30 @@ name: Docker
on:
push:
branches: ['main']
branches: [main]
pull_request:
workflow_dispatch:
jobs:
build:
name: Build image
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
arch: [x86_64, aarch64]
arch: [amd64, arm64]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v13
uses: DeterminateSystems/nix-installer-action@v16
- name: Setup Nix cache
uses: DeterminateSystems/magic-nix-cache-action@v7
uses: DeterminateSystems/magic-nix-cache-action@v8
- name: Build Docker image
id: build
@ -41,10 +44,26 @@ jobs:
if-no-files-found: error
retention-days: 3
# Make sure all above jobs finished successfully
release-gate:
name: Docker Release gate
needs: [build]
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- name: Exit with error
if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
run: exit 1
push:
name: Push image
needs: build
if: ${{ github.event_name == 'push' }}
runs-on: ubuntu-latest
permissions:
@ -54,16 +73,15 @@ jobs:
REGISTRY: ghcr.io
USERNAME: ${{ github.actor }}
if: github.event_name == 'push'
steps:
- uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@v4
- name: Determine image name
run: |
echo "IMAGE_NAME=${REPOSITORY,,}" >> "$GITHUB_ENV"
env:
REPOSITORY: '${{ github.repository }}'
REPOSITORY: ${{ github.repository }}
- name: Download images
uses: actions/download-artifact@v4
@ -83,15 +101,15 @@ jobs:
run: |
set -eu
architectures=("x86_64" "aarch64")
architectures=("amd64" "arm64")
for arch in "${architectures[@]}"; do
docker load < images/container-"$arch"/*.tar.gz
docker tag refraction:latest-"$arch" "$TAG"-"$arch"
docker push ${{ env.TAG }}-"$arch"
docker push "$TAG"-"$arch"
done
docker manifest create "$TAG" \
--amend "$TAG"-x86_64 \
--amend "$TAG"-aarch64
--amend "$TAG"-amd64 \
--amend "$TAG"-arm64
docker manifest push "$TAG"

View file

@ -1,52 +0,0 @@
name: Nix
on:
push:
branches: ['main']
pull_request:
workflow_dispatch:
jobs:
build:
name: Build
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v13
- name: Setup Nix cache
uses: DeterminateSystems/magic-nix-cache-action@v7
- name: Build refraction
run: nix build --fallback --print-build-logs
check:
name: Check flake
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v13
- name: Setup Nix cache
uses: DeterminateSystems/magic-nix-cache-action@v7
- name: Run checks
run: |
nix flake check --print-build-logs --show-trace

View file

@ -15,21 +15,18 @@ jobs:
contents: write
pull-requests: write
env:
PR_BRANCH: 'update-lockfiles'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v13
uses: DeterminateSystems/nix-installer-action@v16
- name: Update flake.lock
id: update
uses: DeterminateSystems/update-flake-lock@main
uses: DeterminateSystems/update-flake-lock@v24
with:
pr-title: "nix: update flake.lock"
pr-title: 'nix: update flake.lock'
- name: Enable Pull Request Automerge
uses: peter-evans/enable-pull-request-automerge@v3

1069
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -22,8 +22,8 @@ env_logger = "0.11.3"
eyre = "0.6.12"
log = "0.4.21"
poise = "0.6.1"
octocrab = "0.39.0"
redis = { version = "0.26.0", features = ["tokio-comp", "tokio-rustls-comp"] }
octocrab = "0.42.0"
redis = { version = "0.27.0", features = ["tokio-comp", "tokio-rustls-comp"] }
regex = "1.10.4"
reqwest = { version = "0.12.4", default-features = false, features = [
"rustls-tls",
@ -36,6 +36,7 @@ tokio = { version = "1.37.0", features = [
"rt-multi-thread",
"signal",
] }
rustls = "0.23.13"
[lints.rust]
unsafe_code = "forbid"

49
flake.lock generated
View file

@ -1,31 +1,16 @@
{
"nodes": {
"flake-checks": {
"locked": {
"lastModified": 1722203301,
"narHash": "sha256-AErsPk8ly2tkiJPieEjN8XuDSc5nJOWv8bv13jmNih0=",
"owner": "getchoo",
"repo": "flake-checks",
"rev": "af23d7bab32b5438ba5602f0ab42dd1d596ef9d7",
"type": "github"
},
"original": {
"owner": "getchoo",
"repo": "flake-checks",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1725036679,
"narHash": "sha256-Ri79ZOEcZJFLr6+LgS3A0WYyroL/PqEuO+lI7u+G2tE=",
"owner": "nixos",
"lastModified": 1731245184,
"narHash": "sha256-vmLS8+x+gHRv1yzj3n+GTAEObwmhxmkkukB2DwtJRdU=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "dac9db29e0e7ff2071ccc47b720aaffc3e74b504",
"rev": "aebe249544837ce42588aa4b2e7972222ba12e8f",
"type": "github"
},
"original": {
"owner": "nixos",
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
@ -33,29 +18,7 @@
},
"root": {
"inputs": {
"flake-checks": "flake-checks",
"nixpkgs": "nixpkgs",
"rust-overlay": "rust-overlay"
}
},
"rust-overlay": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1724984647,
"narHash": "sha256-BC6MUq0CTdmAu/cueVcdWTI+S95s0mJcn19SoEgd7gU=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "87b6cffc276795b46ef544d7ed8d7fed6ad9c8e4",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
"nixpkgs": "nixpkgs"
}
}
},

131
flake.nix
View file

@ -1,23 +1,15 @@
{
description = "Discord bot for Prism Launcher";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-checks.url = "github:getchoo/flake-checks";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = {
outputs =
{
self,
nixpkgs,
flake-checks,
rust-overlay,
}: let
}:
let
inherit (nixpkgs) lib;
systems = [
"x86_64-linux"
"aarch64-linux"
@ -25,22 +17,39 @@
"aarch64-darwin"
];
forAllSystems = fn: nixpkgs.lib.genAttrs systems (system: fn nixpkgs.legacyPackages.${system});
in {
checks = forAllSystems (pkgs: let
flake-checks' = flake-checks.lib.mkChecks {
inherit pkgs;
root = ./.;
};
in {
check-actionlint = flake-checks'.actionlint;
check-alejandra = flake-checks'.alejandra;
check-deadnix = flake-checks'.deadnix;
check-rustfmt = flake-checks'.rustfmt;
check-statix = flake-checks'.statix;
});
forAllSystems = lib.genAttrs systems;
nixpkgsFor = nixpkgs.legacyPackages;
in
{
checks = forAllSystems (
system:
let
pkgs = nixpkgsFor.${system};
mkCheck =
name: deps: script:
pkgs.runCommand name { nativeBuildInputs = deps; } ''
${script}
touch $out
'';
in
{
actionlint = mkCheck "check-actionlint" [ pkgs.actionlint ] "actionlint ${./.github/workflows}/*";
deadnix = mkCheck "check-deadnix" [ pkgs.deadnix ] "deadnix --fail ${self}";
statix = mkCheck "check-statix" [ pkgs.statix ] "statix check ${self}";
nixfmt = mkCheck "check-nixfmt" [ pkgs.nixfmt-rfc-style ] "nixfmt --check ${self}";
rustfmt = mkCheck "check-rustfmt" [
pkgs.cargo
pkgs.rustfmt
] "cd ${self} && cargo fmt -- --check";
}
);
devShells = forAllSystems (pkgs: {
devShells = forAllSystems (
system:
let
pkgs = nixpkgsFor.${system};
in
{
default = pkgs.mkShell {
packages = with pkgs; [
redis
@ -56,7 +65,6 @@
# nix tools
self.formatter.${system}
deadnix
nil
statix
];
@ -64,45 +72,56 @@
inputsFrom = [ self.packages.${pkgs.system}.refraction ];
RUST_SRC_PATH = "${pkgs.rustPlatform.rustLibSrc}";
};
});
}
);
formatter = forAllSystems (pkgs: pkgs.alejandra);
formatter = forAllSystems (system: nixpkgsFor.${system}.nixfmt-rfc-style);
nixosModules.default = import ./nix/module.nix self;
packages = forAllSystems ({
lib,
pkgs,
system,
...
}: let
# For CI
legacyPackages = forAllSystems (
system:
let
pkgs = nixpkgsFor.${system};
in
{
clippy-report = pkgs.callPackage ./nix/clippy.nix { inherit (self.packages.${system}) refraction; };
refraction-debug = (self.packages.${system}.refraction.override { lto = false; }).overrideAttrs (
finalAttrs: _: {
cargoBuildType = "debug";
cargoCheckType = finalAttrs.cargoBuildType;
}
);
}
);
packages = forAllSystems (
system:
let
pkgs = nixpkgsFor.${system};
packages' = self.packages.${system};
mkStatic = pkgs.callPackage ./nix/static.nix {
inherit (self.packages.${pkgs.system}) refraction;
rust-overlay = rust-overlay.packages.${system};
};
refractionPackages = lib.makeScope pkgs.newScope (lib.flip self.overlays.default pkgs);
mkContainerFor = refraction:
pkgs.dockerTools.buildLayeredImage {
name = "refraction";
tag = "latest-${refraction.stdenv.hostPlatform.qemuArch}";
config.Cmd = [(lib.getExe refraction)];
inherit (refraction) architecture;
};
in {
refraction = pkgs.callPackage ./nix/derivation.nix {inherit self;};
mkStatic = pkgs.callPackage ./nix/static.nix { };
containerize = pkgs.callPackage ./nix/containerize.nix { };
in
{
inherit (refractionPackages) refraction;
static-x86_64 = mkStatic { arch = "x86_64"; };
static-aarch64 = mkStatic { arch = "aarch64"; };
container-x86_64 = mkContainerFor packages'.static-x86_64;
container-aarch64 = mkContainerFor packages'.static-aarch64;
container-amd64 = containerize packages'.static-x86_64;
container-arm64 = containerize packages'.static-aarch64;
default = packages'.refraction;
});
}
);
overlays.default = _: prev: {
refraction = prev.callPackage ./nix/derivation.nix {inherit self;};
overlays.default = final: _: {
refraction = final.callPackage ./nix/package.nix { };
};
};
}

39
nix/clippy.nix Normal file
View file

@ -0,0 +1,39 @@
{
cargo,
clippy,
clippy-sarif,
refraction,
rustPlatform,
sarif-fmt,
stdenv,
}:
stdenv.mkDerivation {
pname = "${refraction.pname}-sarif-report";
inherit (refraction)
version
src
cargoDeps
buildInputs
;
nativeBuildInputs = [
cargo
clippy
clippy-sarif
rustPlatform.cargoSetupHook
sarif-fmt
];
buildPhase = ''
cargo clippy \
--all-features \
--all-targets \
--tests \
--message-format=json \
| clippy-sarif | tee $out | sarif-fmt
'';
dontInstall = true;
dontFixup = true;
}

9
nix/containerize.nix Normal file
View file

@ -0,0 +1,9 @@
{ lib, dockerTools }:
refraction:
dockerTools.buildLayeredImage {
name = "refraction";
tag = "latest-${refraction.passthru.dockerArchitecture}";
config.Cmd = [ (lib.getExe refraction) ];
architecture = refraction.passthru.dockerArchitecture;
}

View file

@ -1,67 +0,0 @@
{
lib,
stdenv,
go,
rustPlatform,
darwin,
self,
lto ? true,
optimizeSize ? false,
}:
rustPlatform.buildRustPackage {
pname = "refraction";
version =
(lib.importTOML ../Cargo.toml).package.version
+ "-${self.shortRev or self.dirtyShortRev or "unknown-dirty"}";
__structuredAttrs = true;
src = lib.fileset.toSource {
root = ../.;
fileset = lib.fileset.unions [
../src
../build.rs
../Cargo.lock
../Cargo.toml
../tags
];
};
cargoLock = {
lockFile = ../Cargo.lock;
};
buildInputs = lib.optionals stdenv.hostPlatform.isDarwin (with darwin.apple_sdk.frameworks; [
CoreFoundation
Security
SystemConfiguration
]);
env = let
toRustFlags = lib.mapAttrs' (
name:
lib.nameValuePair
"CARGO_PROFILE_RELEASE_${lib.toUpper (builtins.replaceStrings ["-"] ["_"] name)}"
);
in
lib.optionalAttrs lto (toRustFlags {
lto = "thin";
})
// lib.optionalAttrs optimizeSize (toRustFlags {
codegen-units = "1";
opt-level = "s";
panic = "abort";
strip = "symbols";
});
# useful for container images
passthru.architecture = go.GOARCH;
meta = with lib; {
mainProgram = "refraction";
description = "Discord bot for Prism Launcher";
homepage = "https://github.com/PrismLauncher/refraction";
license = licenses.gpl3Plus;
maintainers = with maintainers; [getchoo Scrumplex];
};
}

View file

@ -1,17 +1,17 @@
self: {
self:
{
config,
lib,
pkgs,
...
}: let
}:
let
cfg = config.services.refraction;
defaultUser = "refraction";
inherit
(lib)
inherit (lib)
getExe
literalExpression
mdDoc
mkEnableOption
mkIf
mkOption
@ -19,13 +19,14 @@ self: {
optionals
types
;
in {
in
{
options.services.refraction = {
enable = mkEnableOption "refraction";
package = mkPackageOption self.packages.${pkgs.stdenv.hostPlatform.system} "refraction" { };
user = mkOption {
description = mdDoc ''
description = ''
User under which the service should run. If this is the default value,
the user will be created, with the specified group as the primary
group.
@ -38,7 +39,7 @@ in {
};
group = mkOption {
description = mdDoc ''
description = ''
Group under which the service should run. If this is the default value,
the group will be created.
'';
@ -50,7 +51,7 @@ in {
};
redisUrl = mkOption {
description = mdDoc ''
description = ''
Connection to a redis server. If this needs to include credentials
that shouldn't be world-readable in the Nix store, set environmentFile
and override the `REDIS_URL` entry.
@ -64,7 +65,7 @@ in {
};
environmentFile = mkOption {
description = mdDoc ''
description = ''
Environment file as defined in {manpage}`systemd.exec(5)`
'';
type = types.nullOr types.path;
@ -85,9 +86,7 @@ in {
systemd.services."refraction" = {
enable = true;
wantedBy = [ "multi-user.target" ];
after =
["network.target"]
++ optionals (cfg.redisUrl == "local") ["redis-refraction.service"];
after = [ "network.target" ] ++ optionals (cfg.redisUrl == "local") [ "redis-refraction.service" ];
script = ''
${getExe cfg.package}
@ -95,9 +94,10 @@ in {
environment = {
BOT_REDIS_URL =
if cfg.redisUrl == "local"
then "unix:${config.services.redis.servers.refraction.unixSocket}"
else cfg.redisUrl;
if cfg.redisUrl == "local" then
"unix:${config.services.redis.servers.refraction.unixSocket}"
else
cfg.redisUrl;
};
serviceConfig = {
@ -141,9 +141,7 @@ in {
};
};
groups = mkIf (cfg.group == defaultUser) {
${defaultUser} = {};
};
groups = mkIf (cfg.group == defaultUser) { ${defaultUser} = { }; };
};
};
}

68
nix/package.nix Normal file
View file

@ -0,0 +1,68 @@
{
lib,
stdenv,
go,
rustPlatform,
lto ? !optimizeSize,
optimizeSize ? false,
}:
let
fs = lib.fileset;
toRustFlags = flags: toString (lib.mapAttrsToList (name: value: "-C ${name}=${value}") flags);
in
assert lib.assertMsg (lto -> !optimizeSize) "`lto` and `optimizeSize` are mutually exclusive";
rustPlatform.buildRustPackage rec {
pname = "refraction";
inherit (passthru.cargoToml.package) version;
src = fs.toSource {
root = ../.;
fileset = fs.intersection (fs.gitTracked ../.) (
fs.unions [
../src
../build.rs
../Cargo.lock
../Cargo.toml
../tags
]
);
};
cargoLock.lockFile = ../Cargo.lock;
# `panic=abort` breaks tests womp womp
doCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform && !optimizeSize;
env = {
RUSTFLAGS = toRustFlags (
lib.optionalAttrs lto {
lto = "thin";
embed-bitcode = "yes";
}
// lib.optionalAttrs optimizeSize {
codegen-units = "1";
opt-level = "s";
panic = "abort";
strip = "symbols";
}
);
};
passthru = {
cargoToml = lib.importTOML ../Cargo.toml;
# For container images
dockerArchitecture = go.GOARCH;
};
meta = {
description = "Discord bot for Prism Launcher";
homepage = "https://github.com/PrismLauncher/refraction";
license = lib.licenses.gpl3Plus;
maintainers = with lib.maintainers; [
getchoo
Scrumplex
];
mainProgram = "refraction";
};
}

View file

@ -1,27 +1,9 @@
{
lib,
refraction,
rust-overlay,
pkgsCross,
}: {arch}: let
targets = with pkgsCross; {
{ pkgsCross }:
let
crossPlatformFor = with pkgsCross; {
x86_64 = musl64.pkgsStatic;
aarch64 = aarch64-multiplatform.pkgsStatic;
};
getRustcTarget = pkgs: pkgs.stdenv.hostPlatform.rust.rustcTarget;
toolchain = rust-overlay.rust.minimal.override {
extensions = ["rust-std"];
targets = lib.mapAttrsToList (lib.const getRustcTarget) targets;
};
mkRustPlatformWith = pkgs:
pkgs.makeRustPlatform (
lib.genAttrs ["cargo" "rustc"] (lib.const toolchain)
);
rustPlatforms = lib.mapAttrs (lib.const mkRustPlatformWith) targets;
in
refraction.override {
rustPlatform = rustPlatforms.${arch};
optimizeSize = true;
}
{ arch }:
crossPlatformFor.${arch}.callPackage ./package.nix { optimizeSize = true; }

View file

@ -1,4 +1,7 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["config:base", "config:recommended", ":automergeMinor"]
"extends": ["config:base", "config:recommended", ":automergeMinor"],
"lockFileMaintenance": {
"enabled": true
}
}

View file

@ -32,6 +32,7 @@ pub async fn find(log: &str, data: &Data) -> Result<Vec<(String, String)>> {
java_32_bit,
intermediary_mappings,
old_forge_new_java,
checksum_mismatch,
];
let mut res: Vec<(String, String)> = issues.iter().filter_map(|issue| issue(log)).collect();
@ -123,9 +124,9 @@ fn java_option(log: &str) -> Issue {
if let Some(captures) = vm_option.captures(log) {
let title = if &captures[1] == "UseShenandoahGC" {
"Wrong Java Arguments"
} else {
"Java 8 and below don't support ShenandoahGC"
} else {
"Wrong Java Arguments"
};
return Some((
title.to_string(),
@ -370,7 +371,8 @@ fn java_32_bit(log: &str) -> Issue {
);
let found = log.contains("Could not reserve enough space for ")
|| log.contains("Invalid maximum heap size: ");
|| log.contains("Invalid maximum heap size: ")
|| log.contains("Invalid initial heap size: ");
found.then_some(issue)
}
@ -399,3 +401,15 @@ fn old_forge_new_java(log: &str) -> Issue {
);
found.then_some(issue)
}
fn checksum_mismatch(log: &str) -> Issue {
let issue = (
"Outdated cached files".to_string(),
"It looks like you need to delete cached files.
To do that, press Folders View Launcher Root Folder, and **after closing the launcher** delete the folder named \"meta\"."
.to_string(),
);
let found = log.contains("Checksum mismatch, download is bad.");
found.then_some(issue)
}

View file

@ -41,6 +41,8 @@ pub async fn handle(ctx: &Context, message: &Message, data: &Data) -> Result<()>
return Ok(());
};
let log = log.replace("\r\n", "\n");
let issues = issues::find(&log, data).await?;
let embed = {

View file

@ -42,7 +42,7 @@ pub async fn handle(
// ignore new messages from bots
// note: the webhook_id check allows us to still respond to PK users
if (new_message.author.bot && new_message.webhook_id.is_none())
|| new_message.is_own(ctx)
|| (new_message.author == **ctx.cache.current_user())
{
trace!("Ignoring message {} from bot", new_message.id);
return Ok(());

View file

@ -58,7 +58,7 @@ async fn setup(
trace!("Redis connection looks good!");
}
let http_client = api::HttpClient::default();
let http_client = <api::HttpClient as api::HttpClientExt>::default();
let octocrab = octocrab::instance();
let data = Data {
@ -85,6 +85,9 @@ async fn main() -> eyre::Result<()> {
dotenvy::dotenv().ok();
color_eyre::install()?;
env_logger::init();
rustls::crypto::aws_lc_rs::default_provider()
.install_default()
.expect("Couldn't initialize crypto provider");
let token =
std::env::var("DISCORD_BOT_TOKEN").wrap_err("Couldn't find bot token in environment!")?;

View file

@ -35,7 +35,7 @@ impl Storage {
let mut con = self.client.get_multiplexed_async_connection().await?;
// Just store some value. We only care about the presence of this key
con.set_ex(key, 0, 7 * 24 * 60 * 60).await?; // 1 week
() = con.set_ex(key, 0, 7 * 24 * 60 * 60).await?; // 1 week
Ok(())
}
@ -54,7 +54,8 @@ impl Storage {
debug!("Caching launcher version as {version}");
let mut con = self.client.get_multiplexed_async_connection().await?;
con.set_ex(LAUNCHER_VERSION_KEY, version, 24 * 60 * 60)
() = con
.set_ex(LAUNCHER_VERSION_KEY, version, 24 * 60 * 60)
.await?; // 1 day
Ok(())
@ -73,7 +74,8 @@ impl Storage {
debug!("Caching stargazer count as {stargazers}");
let mut con = self.client.get_multiplexed_async_connection().await?;
con.set_ex(LAUNCHER_STARGAZER_KEY, stargazers, 60 * 60)
() = con
.set_ex(LAUNCHER_STARGAZER_KEY, stargazers, 60 * 60)
.await?;
Ok(())

View file

@ -1,10 +0,0 @@
---
title: Prism Launcher is always offline?
color: orange
---
If you recently updated Prism Launcher on Windows and you are now unable to do anything in Prism Launcher that would require an internet connection (i.e. logging in, downloading mods/modpacks and more), try uninstalling the launcher and then reinstalling it again.
If you are using a portable installation, it should be sufficient to delete the `tls` folder and then extract the zip again.
See [this GitHub issue](https://github.com/PrismLauncher/PrismLauncher/issues/660) for more information.

View file

@ -3,4 +3,4 @@ title: Java Instructions
color: orange
---
Currently, Prism Launcher does not bundle Java with itself. The instructions to setup and install Java can be found [here](https://prismlauncher.org/wiki/getting-started/installing-java/).
As of 9.0, Prism Launcher will automatically download and configure Java for the version of Minecraft you are using. The instructions to manually setup and install Java can be found [here](https://prismlauncher.org/wiki/getting-started/installing-java/).

View file

@ -1,10 +0,0 @@
---
title: Forge Bugfix
color: yellow
image: https://media.discordapp.net/attachments/1040383700845740072/1057840239751729172/Fix.png
---
1. Click the instance that is broken, then select `Edit`.
2. Choose `Version` and then click `Forge`, then click the change version button.
3. You can then change the version, choose the latest, and click OK.
4. You are good to go! <a:minecraftpartyparrotr:1032312401577652274>

10
tags/login_fix.md Normal file
View file

@ -0,0 +1,10 @@
---
title: Microsoft login
color: orange
---
If you have trouble with Microsoft login make sure:
* The age stated in your account is over 21.
* Microsoft auth servers are not experiencing downtime.
For more possible solutions check this GitHub issue [#2302](https://github.com/PrismLauncher/PrismLauncher/issues/2302).

View file

@ -0,0 +1,7 @@
---
title: Minecraft Launcher Comparison
color: green
---
Here is a comparison of the features of various launchers, including Prism Launcher:
https://mc-launcher.tayou.org/

20
tags/prism_logs.md Normal file
View file

@ -0,0 +1,20 @@
---
title: Upload Logs
color: orange
fields:
- name: Portable (Windows / Linux)
value: '`./logs/PrismLauncher-0.log` In the PrismLauncher folder'
- name: Windows
value: '`%APPDATA%/PrismLauncher/logs/PrismLauncher-0.log`'
- name: Scoop
value: '`%HOMEPATH%\scoop\persist\prismlauncher\logs\PrismLauncher-0.log`'
- name: macOS
value: '`~/Library/Application Support/PrismLauncher/logs/PrismLauncher-0.log`'
- name: Linux
value: '`~/.local/share/PrismLauncher/logs/PrismLauncher-0.log`'
- name: Flatpak
value: '`~/.var/app/org.prismlauncher.PrismLauncher/data/PrismLauncher/logs/PrismLauncher-0.log`'
---
Please send logs! The recommended site to upload your logs to is [mclo.gs](https://mclo.gs/).