Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into boy132/fix-admin-se…
Browse files Browse the repository at this point in the history
…rver-access
  • Loading branch information
Boy132 committed Jan 17, 2025
2 parents 44ba4fb + cbacc18 commit 63dd0bb
Show file tree
Hide file tree
Showing 57 changed files with 579 additions and 1,335 deletions.
75 changes: 0 additions & 75 deletions .github/docker/default.conf

This file was deleted.

70 changes: 0 additions & 70 deletions .github/docker/default_ssl.conf

This file was deleted.

16 changes: 0 additions & 16 deletions .github/docker/www.conf

This file was deleted.

24 changes: 13 additions & 11 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
name: Docker


on:
push:
branches:
Expand All @@ -15,17 +14,23 @@ env:

jobs:
build-and-push:
name: Build and Push
runs-on: ubuntu-latest
name: Build and Push ${{ matrix.os }}
runs-on: ${{ matrix.os }}
permissions:
contents: read
packages: write

strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04, ubuntu-24.04-arm]
# Always run against a tag, even if the commit into the tag has [docker skip] within the commit message.
if: "!contains(github.ref, 'main') || (!contains(github.event.head_commit.message, 'skip docker') && !contains(github.event.head_commit.message, 'docker skip'))"

steps:
- name: Code checkout
uses: actions/checkout@v4

- name: Docker metadata
id: docker_meta
uses: docker/metadata-action@v5
Expand All @@ -38,9 +43,6 @@ jobs:
type=ref,event=tag
type=ref,event=branch
- name: Setup QEMU
uses: docker/setup-qemu-action@v3

- name: Setup Docker buildx
uses: docker/setup-buildx-action@v3

Expand All @@ -58,26 +60,26 @@ jobs:
echo "short_sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Build and Push (tag)
uses: docker/build-push-action@v5
uses: docker/build-push-action@v6
if: "github.event_name == 'release' && github.event.action == 'published'"
with:
context: .
file: ./Dockerfile
push: true
platforms: linux/amd64,linux/arm64
platforms: ${{ matrix.os == 'ubuntu-24.04' && 'linux/amd64' || 'linux/arm64' }}
build-args: |
VERSION=${{ steps.build_info.outputs.version_tag }}
labels: ${{ steps.docker_meta.outputs.labels }}
tags: ${{ steps.docker_meta.outputs.tags }}

- name: Build and Push (main)
uses: docker/build-push-action@v5
uses: docker/build-push-action@v6
if: "github.event_name == 'push' && contains(github.ref, 'main')"
with:
context: .
file: ./Dockerfile
push: ${{ github.event_name != 'pull_request' }}
platforms: linux/amd64,linux/arm64
platforms: ${{ matrix.os == 'ubuntu-24.04' && 'linux/amd64' || 'linux/arm64' }}
build-args: |
VERSION=dev-${{ steps.build_info.outputs.short_sha }}
labels: ${{ steps.docker_meta.outputs.labels }}
Expand Down
14 changes: 6 additions & 8 deletions app/Console/Commands/Schedule/ProcessRunnableCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,15 @@
use App\Models\Schedule;
use Illuminate\Database\Eloquent\Builder;
use App\Services\Schedules\ProcessScheduleService;
use Throwable;

class ProcessRunnableCommand extends Command
{
protected $signature = 'p:schedule:process';

protected $description = 'Process schedules in the database and determine which are ready to run.';

/**
* Handle command execution.
*/
public function handle(): int
public function handle(ProcessScheduleService $processScheduleService): int
{
$schedules = Schedule::query()
->with('tasks')
Expand All @@ -35,7 +33,7 @@ public function handle(): int
$bar = $this->output->createProgressBar(count($schedules));
foreach ($schedules as $schedule) {
$bar->clear();
$this->processSchedule($schedule);
$this->processSchedule($processScheduleService, $schedule);
$bar->advance();
$bar->display();
}
Expand All @@ -50,20 +48,20 @@ public function handle(): int
* never throw an exception out, otherwise you'll end up killing the entire run group causing
* any other schedules to not process correctly.
*/
protected function processSchedule(Schedule $schedule): void
protected function processSchedule(ProcessScheduleService $processScheduleService, Schedule $schedule): void
{
if ($schedule->tasks->isEmpty()) {
return;
}

try {
$this->getLaravel()->make(ProcessScheduleService::class)->handle($schedule);
$processScheduleService->handle($schedule);

$this->line(trans('command/messages.schedule.output_line', [
'schedule' => $schedule->name,
'id' => $schedule->id,
]));
} catch (\Throwable|\Exception $exception) {
} catch (Throwable $exception) {
logger()->error($exception, ['schedule_id' => $schedule->id]);

$this->error(__('commands.schedule.process.no_tasks') . " #$schedule->id: " . $exception->getMessage());
Expand Down
28 changes: 10 additions & 18 deletions app/Console/Commands/Server/BulkPowerActionCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,13 @@ class BulkPowerActionCommand extends Command

protected $description = 'Perform bulk power management on large groupings of servers or nodes at once.';

/**
* BulkPowerActionCommand constructor.
*/
public function __construct(private DaemonPowerRepository $powerRepository, private ValidatorFactory $validator)
{
parent::__construct();
}

/**
* Handle the bulk power request.
*
* @throws \Illuminate\Validation\ValidationException
*/
public function handle(): void
public function handle(DaemonPowerRepository $powerRepository, ValidatorFactory $validator): void
{
$action = $this->argument('action');
$nodes = empty($this->option('nodes')) ? [] : explode(',', $this->option('nodes'));
$servers = empty($this->option('servers')) ? [] : explode(',', $this->option('servers'));

$validator = $this->validator->make([
$validator = $validator->make([
'action' => $action,
'nodes' => $nodes,
'servers' => $servers,
Expand All @@ -64,11 +51,14 @@ public function handle(): void
}

$bar = $this->output->createProgressBar($count);
$powerRepository = $this->powerRepository;
// @phpstan-ignore-next-line
$this->getQueryBuilder($servers, $nodes)->each(function (Server $server) use ($action, $powerRepository, &$bar) {

$this->getQueryBuilder($servers, $nodes)->get()->each(function ($server, int $index) use ($action, $powerRepository, &$bar): mixed {
$bar->clear();

if (!$server instanceof Server) {
return null;
}

try {
$powerRepository->setServer($server)->send($action);
} catch (Exception $exception) {
Expand All @@ -82,6 +72,8 @@ public function handle(): void

$bar->advance();
$bar->display();

return null;
});

$this->line('');
Expand Down
4 changes: 0 additions & 4 deletions app/Console/Commands/UpgradeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ public function handle(): void
$this->line($this->getUrl());
}

if (version_compare(PHP_VERSION, '7.4.0') < 0) {
$this->error(__('commands.upgrade.php_version') . ' [' . PHP_VERSION . '].');
}

$user = 'www-data';
$group = 'www-data';
if ($this->input->isInteractive()) {
Expand Down
24 changes: 24 additions & 0 deletions app/Eloquent/BackupQueryBuilder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace App\Eloquent;

use Illuminate\Database\Eloquent\Builder;

/**
* @template TModel of \Illuminate\Database\Eloquent\Model
*
* @extends Builder<TModel>
*/
class BackupQueryBuilder extends Builder
{
public function nonFailed(): self
{
$this->where(function (Builder $query) {
$query
->whereNull('completed_at')
->orWhere('is_successful', true);
});

return $this;
}
}
2 changes: 1 addition & 1 deletion app/Enums/EditorLanguages.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ enum EditorLanguages: string implements HasLabel
case yaml = 'yaml';
case json = 'json';

public function getLabel(): ?string
public function getLabel(): string
{
return $this->name;
}
Expand Down
Loading

0 comments on commit 63dd0bb

Please sign in to comment.