Skip to content

Commit a53bdb4

Browse files
committed
Merge branch 'release/v1.0.0'
2 parents 4fd78cf + 061f0e5 commit a53bdb4

File tree

400 files changed

+20443
-8035
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

400 files changed

+20443
-8035
lines changed

.github/workflows/docker-dev.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Docker Build Dev
2+
3+
on:
4+
push:
5+
branches: [ develop ]
6+
7+
jobs:
8+
phpunit:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
13+
- name: Installing PHP
14+
uses: shivammathur/setup-php@master
15+
with:
16+
php-version: '7.4'
17+
- name: Get Composer Cache Directory 2
18+
id: composer-cache
19+
run: |
20+
echo "::set-output name=dir::$(composer config cache-files-dir)"
21+
- uses: actions/cache@v2
22+
id: actions-cache
23+
with:
24+
path: ${{ steps.composer-cache.outputs.dir }}
25+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
26+
restore-keys: |
27+
${{ runner.os }}-composer-
28+
- name: Cache PHP dependencies
29+
uses: actions/cache@v2
30+
id: vendor-cache
31+
with:
32+
path: vendor
33+
key: ${{ runner.OS }}-build-${{ hashFiles('**/composer.lock') }}
34+
- name: Setup env file
35+
run: cp .env.ci .env
36+
- name: test ls
37+
run: ls -lao
38+
- name: Composer install
39+
if: steps.vendor-cache.outputs.cache-hit != 'true'
40+
run: composer install --no-ansi --no-interaction --no-scripts --no-suggest --prefer-dist
41+
- name: Setup keys
42+
run: php artisan key:generate
43+
- name: Fix perms for dirs
44+
run: chmod -R 777 storage bootstrap/cache
45+
- name: Migrate database
46+
env:
47+
DB_CONNECTION: 'sqlite'
48+
DB_DATABASE: 'db.sqlite'
49+
run: touch database/db.sqlite; php artisan migrate
50+
- name: Execute tests (Unit and Feature tests) via PHPUnit
51+
env:
52+
DB_CONNECTION: 'sqlite'
53+
DB_DATABASE: 'db.sqlite'
54+
run: vendor/phpunit/phpunit/phpunit
55+
main:
56+
runs-on: ubuntu-latest
57+
needs: phpunit
58+
steps:
59+
-
60+
name: Set up QEMU
61+
uses: docker/setup-qemu-action@v1
62+
-
63+
name: Set up Docker Buildx
64+
uses: docker/setup-buildx-action@v1
65+
-
66+
name: Cache Docker layers
67+
uses: actions/cache@v2
68+
with:
69+
path: /tmp/.buildx-cache
70+
key: ${{ runner.os }}-buildx-${{ github.sha }}
71+
restore-keys: |
72+
${{ runner.os }}-buildx-
73+
-
74+
name: Login to DockerHub
75+
uses: docker/login-action@v1
76+
with:
77+
username: ${{ secrets.DOCKERHUB_USERNAME }}
78+
password: ${{ secrets.DOCKERHUB_TOKEN }}
79+
-
80+
name: Build and push
81+
id: docker_build
82+
uses: docker/build-push-action@v2
83+
with:
84+
tags: scwiki/api:dev
85+
push: true
86+
cache-from: type=local,src=/tmp/.buildx-cache
87+
cache-to: type=local,dest=/tmp/.buildx-cache

.github/workflows/docker.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Docker Build
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
7+
jobs:
8+
phpunit:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
13+
- name: Installing PHP
14+
uses: shivammathur/setup-php@master
15+
with:
16+
php-version: '7.4'
17+
- name: Get Composer Cache Directory 2
18+
id: composer-cache
19+
run: |
20+
echo "::set-output name=dir::$(composer config cache-files-dir)"
21+
- uses: actions/cache@v2
22+
id: actions-cache
23+
with:
24+
path: ${{ steps.composer-cache.outputs.dir }}
25+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
26+
restore-keys: |
27+
${{ runner.os }}-composer-
28+
- name: Cache PHP dependencies
29+
uses: actions/cache@v2
30+
id: vendor-cache
31+
with:
32+
path: vendor
33+
key: ${{ runner.OS }}-build-${{ hashFiles('**/composer.lock') }}
34+
- name: Setup env file
35+
run: cp .env.ci .env
36+
- name: test ls
37+
run: ls -lao
38+
- name: Composer install
39+
if: steps.vendor-cache.outputs.cache-hit != 'true'
40+
run: composer install --no-ansi --no-interaction --no-scripts --no-suggest --prefer-dist
41+
- name: Setup keys
42+
run: php artisan key:generate
43+
- name: Fix perms for dirs
44+
run: chmod -R 777 storage bootstrap/cache
45+
- name: Migrate database
46+
env:
47+
DB_CONNECTION: 'sqlite'
48+
DB_DATABASE: 'db.sqlite'
49+
run: touch database/db.sqlite; php artisan migrate
50+
- name: Execute tests (Unit and Feature tests) via PHPUnit
51+
env:
52+
DB_CONNECTION: 'sqlite'
53+
DB_DATABASE: 'db.sqlite'
54+
run: vendor/phpunit/phpunit/phpunit
55+
main:
56+
runs-on: ubuntu-latest
57+
needs: phpunit
58+
steps:
59+
-
60+
name: Set up QEMU
61+
uses: docker/setup-qemu-action@v1
62+
-
63+
name: Set up Docker Buildx
64+
uses: docker/setup-buildx-action@v1
65+
-
66+
name: Login to DockerHub
67+
uses: docker/login-action@v1
68+
with:
69+
username: ${{ secrets.DOCKERHUB_USERNAME }}
70+
password: ${{ secrets.DOCKERHUB_TOKEN }}
71+
-
72+
name: Build and push
73+
id: docker_build
74+
uses: docker/build-push-action@v2
75+
with:
76+
tags: scwiki/api:latest
77+
push: true

.github/workflows/phpunit.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ jobs:
1010
steps:
1111
- uses: actions/checkout@v2
1212

13+
- name: Installing PHP
14+
uses: shivammathur/setup-php@master
15+
with:
16+
php-version: '7.4'
1317
- name: Get Composer Cache Directory 2
1418
id: composer-cache
1519
run: |
@@ -68,6 +72,10 @@ jobs:
6872
steps:
6973
- uses: actions/checkout@v2
7074

75+
- name: Installing PHP
76+
uses: shivammathur/setup-php@master
77+
with:
78+
php-version: '7.4'
7179
- name: Get Composer Cache Directory 2
7280
id: composer-cache
7381
run: |

Dockerfile

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@ LABEL stage=intermediate
7272

7373
WORKDIR /api
7474

75-
COPY composer.json composer.lock /api/
76-
7775
# install git
7876
RUN apt-get update && \
7977
apt-get install -y zip unzip
8078

81-
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
79+
COPY composer.json composer.lock /api/
80+
81+
COPY --from=composer:1 /usr/bin/composer /usr/bin/composer
8282

8383
RUN /usr/bin/composer install --no-dev \
8484
--ignore-platform-reqs \
@@ -88,11 +88,19 @@ RUN /usr/bin/composer install --no-dev \
8888
--no-scripts
8989

9090
COPY / /api
91+
9192
RUN /usr/bin/composer dump-autoload --optimize --classmap-authoritative
9293

9394
### Final Image
9495
FROM php:7.4-apache
9596

97+
RUN apt-get update && \
98+
apt-get install -y --no-install-recommends \
99+
libfreetype6-dev \
100+
libjpeg62-turbo-dev \
101+
libwebp-dev \
102+
libpng-dev
103+
96104
WORKDIR /var/www/html
97105

98106
COPY --from=api /api /var/www/html
@@ -102,21 +110,20 @@ COPY ./docker/start.sh /usr/local/bin/start
102110
COPY --from=extensions /usr/local/etc/php/conf.d/*.ini /usr/local/etc/php/conf.d/
103111
COPY --from=extensions /usr/local/lib/php/extensions/no-debug-non-zts-20190902/*.so /usr/local/lib/php/extensions/no-debug-non-zts-20190902/
104112

105-
RUN apt-get update && \
106-
apt-get install -y --no-install-recommends \
107-
libfreetype6-dev \
108-
libjpeg62-turbo-dev \
109-
libwebp-dev \
110-
libpng-dev
111-
112113
RUN sed -i -e "s/extension=zip.so/;extension=zip.so/" /usr/local/etc/php/conf.d/docker-php-ext-zip.ini && \
113114
echo 'memory_limit = 512M' >> /usr/local/etc/php/conf.d/docker-php-memlimit.ini && \
114115
echo 'max_execution_time = 60' >> /usr/local/etc/php/conf.d/docker-php-executiontime.ini
115116

116-
RUN chown -R www-data:www-data /var/www/html && \
117-
chmod u+x /usr/local/bin/start && \
118-
chmod -R u+w /var/www/html/storage && \
119-
chmod -R g+w /var/www/html/storage && \
117+
COPY ./docker/schedule.sh /usr/local/bin/schedule
118+
119+
RUN chown -R www-data:www-data /var/www/html; \
120+
chmod u+x /usr/local/bin/start; \
121+
chmod -R u+w /var/www/html/storage; \
122+
chmod -R g+w /var/www/html/storage; \
123+
chown www-data:www-data /usr/local/bin/schedule; \
124+
chmod +x /usr/local/bin/schedule; \
120125
a2enmod rewrite
121126

127+
USER root
128+
122129
CMD ["/usr/local/bin/start"]
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Console\Commands\CommLink;
6+
7+
use App\Jobs\Rsi\CommLink\Download\DownloadMissingCommLinks;
8+
use App\Jobs\Rsi\CommLink\Import\ImportCommLinks;
9+
use Illuminate\Console\Command;
10+
11+
class CommLinkSchedule extends Command
12+
{
13+
/**
14+
* The name and signature of the console command.
15+
*
16+
* @var string
17+
*/
18+
protected $signature = 'comm-links:schedule';
19+
20+
/**
21+
* The console command description.
22+
*
23+
* @var string
24+
*/
25+
protected $description = 'Download missing Comm-Links. Parse the download, create metadata and hashes. ' .
26+
'If a DeepL API key is set, Comm-Links will be translated. ' .
27+
'If a MediaWiki Account is configured, Wiki Comm-Link pages will be created';
28+
29+
/**
30+
* Execute the console command.
31+
*
32+
* @return int
33+
*/
34+
public function handle(): int
35+
{
36+
DownloadMissingCommLinks::dispatch()->chain(
37+
[
38+
new ImportCommLinks(60),
39+
]
40+
);
41+
42+
return 0;
43+
}
44+
}

app/Console/Commands/CommLink/Download/DownloadCommLink.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use App\Console\Commands\CommLink\Image\CreateImageHashes;
99
use App\Jobs\Rsi\CommLink\Download\DownloadCommLink as DownloadCommLinkJob;
1010
use App\Jobs\Rsi\CommLink\Image\CreateImageMetadata;
11-
use App\Jobs\Rsi\CommLink\Parser\ParseCommLinkDownload;
11+
use App\Jobs\Rsi\CommLink\Import\ImportCommLinks;
1212
use Illuminate\Bus\Dispatcher;
1313
use Illuminate\Support\Collection;
1414

@@ -75,8 +75,14 @@ function (Collection $collection) {
7575
)
7676
->each(
7777
function (int $id) {
78+
$skipExisting = true;
79+
80+
if ($this->option('overwrite') === true) {
81+
$skipExisting = false;
82+
}
83+
7884
$this->info('Downloading specified Comm-Links');
79-
$this->dispatcher->dispatch(new DownloadCommLinkJob($id, $this->option('overwrite') === true));
85+
$this->dispatcher->dispatch(new DownloadCommLinkJob($id, $skipExisting));
8086
$this->advanceBar();
8187
}
8288
)
@@ -99,7 +105,7 @@ function (int $id) {
99105
private function dispatchImportJob(int $minId): void
100106
{
101107
$this->info("\nImporting Comm-Links");
102-
$this->dispatcher->dispatch(new ParseCommLinkDownload($minId));
108+
$this->dispatcher->dispatch(new ImportCommLinks($minId));
103109
$this->dispatcher->dispatch(new CreateImageMetadata());
104110
$this->dispatcher->dispatch(new CreateImageHashes());
105111
}

app/Console/Commands/CommLink/Download/ReDownloadCommLinks.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace App\Console\Commands\CommLink\Download;
66

77
use App\Jobs\Rsi\CommLink\Download\ReDownloadDbCommLinks;
8-
use App\Jobs\Rsi\CommLink\Parser\ParseCommLinkDownload;
8+
use App\Jobs\Rsi\CommLink\Import\ImportCommLinks;
99
use Illuminate\Console\Command;
1010

1111
/**
@@ -42,7 +42,7 @@ public function handle(): int
4242

4343
ReDownloadDbCommLinks::withChain(
4444
[
45-
new ParseCommLinkDownload(),
45+
new ImportCommLinks(),
4646
]
4747
)->dispatch($skip);
4848

app/Console/Commands/CommLink/Import/ImportCommLink.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace App\Console\Commands\CommLink\Import;
66

7-
use App\Jobs\Rsi\CommLink\Parser\ParseCommLink;
7+
use App\Jobs\Rsi\CommLink\Import\ImportCommLink as ImportCommLinkJob;
88
use App\Models\Rsi\CommLink\CommLink;
99
use Illuminate\Console\Command;
1010
use Illuminate\Database\Eloquent\ModelNotFoundException;
@@ -52,7 +52,7 @@ public function handle(): int
5252

5353
$file = basename(Arr::last(Storage::disk('comm_links')->files($id)));
5454

55-
dispatch(new ParseCommLink($id, $file, $commLink, true));
55+
dispatch(new ImportCommLinkJob($id, $file, $commLink, true));
5656

5757
return 0;
5858
}

0 commit comments

Comments
 (0)