-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 4b565ec
Showing
27 changed files
with
785 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
APP_UID=1000 | ||
APP_GID=1000 | ||
|
||
MOONBOARD_USERNAME= | ||
MOONBOARD_PASSWORD= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Path-based git attributes | ||
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html | ||
|
||
# Ignore all test and documentation with "export-ignore". | ||
/.env.example export-ignore | ||
/.gitattributes export-ignore | ||
/.github/ export-ignore | ||
/.gitignore export-ignore | ||
/.php-cs-fixer.dist.php export-ignore | ||
/CHANGELOG.md export-ignore | ||
/docker/ export-ignore | ||
/docker-compose.yml export-ignore | ||
/phpstan.neon.dist export-ignore | ||
/phpunit.xml.dist export-ignore | ||
/tests/ export-ignore | ||
/vendor-bin/ export-ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# These are supported funding model platforms | ||
|
||
github: ngmy | ||
patreon: # Replace with a single Patreon username | ||
open_collective: # Replace with a single Open Collective username | ||
ko_fi: # Replace with a single Ko-fi username | ||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel | ||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry | ||
liberapay: # Replace with a single Liberapay username | ||
issuehunt: # Replace with a single IssueHunt username | ||
otechie: # Replace with a single Otechie username | ||
custom: https://flattr.com/@ngmy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Lint | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
lint: | ||
|
||
runs-on: ubuntu-20.04 | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
php: ['8.2'] | ||
|
||
name: PHP ${{ matrix.php }} | ||
|
||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up PHP ${{ matrix.php }} | ||
run: sudo update-alternatives --set php /usr/bin/php${{ matrix.php }} | ||
|
||
- name: Update Composer to latest version | ||
run: sudo composer self-update | ||
|
||
- name: Validate composer.json | ||
run: composer validate | ||
|
||
- name: Install Composer dependencies | ||
run: | | ||
composer install --no-interaction | ||
- name: Run lint | ||
run: composer lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: Test | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
test: | ||
|
||
runs-on: ubuntu-20.04 | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
php: ['8.2'] | ||
|
||
name: PHP ${{ matrix.php }} | ||
|
||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up PHP ${{ matrix.php }} | ||
run: sudo update-alternatives --set php /usr/bin/php${{ matrix.php }} | ||
|
||
- name: Update Composer to latest version | ||
run: sudo composer self-update | ||
|
||
- name: Validate composer.json | ||
run: composer validate | ||
|
||
- name: Install Composer dependencies | ||
run: | | ||
composer install --no-interaction | ||
- name: Run tests | ||
run: | | ||
composer test-coverage | ||
- name: Upload coverage results to Coveralls | ||
env: | ||
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
uses: nick-fields/retry@v2 | ||
with: | ||
timeout_minutes: 10 | ||
max_attempts: 3 | ||
command: vendor-bin/php-coveralls/vendor/bin/php-coveralls --coverage_clover=build/logs/clover.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Dotenv | ||
/.env | ||
|
||
# Composer | ||
/composer.lock | ||
/vendor/ | ||
/vendor-bin/**/composer.lock | ||
/vendor-bin/**/vendor/ | ||
|
||
# Build | ||
/build/ | ||
|
||
# PHPUnit | ||
/.phpunit.cache/ | ||
/phpunit.xml | ||
|
||
# PHPStan | ||
/phpstan.neon | ||
|
||
# PHP CS Fixer | ||
/.php-cs-fixer.php | ||
/.php-cs-fixer.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
$finder = PhpCsFixer\Finder::create() | ||
->in(__DIR__) | ||
; | ||
|
||
$config = new PhpCsFixer\Config(); | ||
|
||
return $config->setRules([ | ||
'@PHP80Migration:risky' => true, | ||
'@PHP81Migration' => true, | ||
'@PhpCsFixer' => true, | ||
'@PhpCsFixer:risky' => true, | ||
'@PHPUnit100Migration:risky' => true, | ||
]) | ||
->setFinder($finder) | ||
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Release Notes | ||
|
||
## 0.1.0 - 2023-11-04 | ||
|
||
- Initial release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 Yuta Nagamiya | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# MoonBoard Web Scraper | ||
|
||
A web scraper for MoonBoard website. | ||
|
||
## Installation | ||
|
||
Clone this repository and install Composer packages: | ||
|
||
```bash | ||
git clone https://github.com/ngmy/moonboard-web-scraper.git | ||
|
||
cd moonboard-web-scraper | ||
|
||
composer install --no-dev | ||
``` | ||
|
||
Also, set your MoonBoard username and password to the `MOONBOARD_USERNAME` and `MOONBOARD_PASSWORD` environment | ||
variables. | ||
|
||
## Usage | ||
|
||
### Scrape benchmarks | ||
|
||
```bash | ||
bin/moonboard-web-scraper scrape-benchmarks | ||
``` | ||
|
||
## Changelog | ||
|
||
Please see the [changelog](CHANGELOG.md). | ||
|
||
## License | ||
|
||
MoonBoard Web Scraper is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
|
||
require __DIR__ . '/../vendor/autoload.php'; | ||
|
||
use App\Commands\ScrapeBenchmarksCommand; | ||
use App\Models\HoldSetups; | ||
use App\Services\Authenticator; | ||
use App\UseCases\ScrapeBenchmarksAction; | ||
use Symfony\Component\Console\Application; | ||
use Symfony\Component\Panther\Client; | ||
|
||
$client = Client::createChromeClient( | ||
arguments: [ | ||
'--disable-dev-shm-usage', | ||
'--headless', | ||
'--no-sandbox', | ||
'--window-size=1500,1500' | ||
], | ||
baseUri: 'https://www.moonboard.com', | ||
); | ||
$application = new Application(); | ||
$application->add(new ScrapeBenchmarksCommand( | ||
new ScrapeBenchmarksAction( | ||
client: $client, | ||
authenticator: new Authenticator( | ||
username: getenv('MOONBOARD_USERNAME'), | ||
password: getenv('MOONBOARD_PASSWORD'), | ||
), | ||
holdSetups: HoldSetups::all(), | ||
), | ||
)); | ||
$application->run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
{ | ||
"name": "ngmy/moonboard-web-scraper", | ||
"description": "A web scraper for MoonBoard website.", | ||
"license": "MIT", | ||
"type": "project", | ||
"keywords": [ | ||
"moonboard", | ||
"scraper" | ||
], | ||
"authors": [ | ||
{ | ||
"name": "Yuta Nagamiya", | ||
"email": "y.nagamiya@gmail.com" | ||
} | ||
], | ||
"homepage": "https://github.com/ngmy/moonboard-web-scraper", | ||
"require": { | ||
"php": "^8.2", | ||
"ext-zip": "*", | ||
"symfony/console": "^6.3", | ||
"symfony/panther": "^2.1" | ||
}, | ||
"require-dev": { | ||
"bamarni/composer-bin-plugin": "^1.8", | ||
"ergebnis/composer-normalize": "^2.39", | ||
"phpstan/extension-installer": "^1.3", | ||
"phpstan/phpstan": "^1.10" | ||
}, | ||
"minimum-stability": "stable", | ||
"prefer-stable": true, | ||
"autoload": { | ||
"psr-4": { | ||
"App\\": "src/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"Tests\\": "tests/" | ||
} | ||
}, | ||
"config": { | ||
"allow-plugins": { | ||
"bamarni/composer-bin-plugin": true, | ||
"ergebnis/composer-normalize": true, | ||
"phpstan/extension-installer": true | ||
}, | ||
"preferred-install": "dist", | ||
"sort-packages": true | ||
}, | ||
"extra": { | ||
"bamarni-bin": { | ||
"bin-links": false, | ||
"forward-command": true, | ||
"target-directory": "vendor-bin" | ||
} | ||
}, | ||
"scripts": { | ||
"fmt": [ | ||
"@php vendor-bin/php-cs-fixer/vendor/bin/php-cs-fixer fix --allow-risky=yes" | ||
], | ||
"lint": [ | ||
"Composer\\Config::disableProcessTimeout", | ||
"@php vendor/bin/phpstan clear-result-cache || exit $?", | ||
"@php vendor/bin/phpstan analyse" | ||
], | ||
"test": [ | ||
"@php vendor-bin/phpunit/vendor/bin/phpunit --no-coverage" | ||
], | ||
"test-coverage": [ | ||
"@putenv XDEBUG_MODE=coverage", | ||
"@php vendor-bin/phpunit/vendor/bin/phpunit" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
version: "3.7" | ||
|
||
services: | ||
app: | ||
build: | ||
context: ./docker/php | ||
args: | ||
UID: ${APP_UID} | ||
GID: ${APP_GID} | ||
tty: true | ||
environment: | ||
MOONBOARD_USERNAME: ${MOONBOARD_USERNAME} | ||
MOONBOARD_PASSWORD: ${MOONBOARD_PASSWORD} | ||
volumes: | ||
- .:/var/www | ||
working_dir: /var/www |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
FROM php:8.2 | ||
|
||
ARG USERNAME=app | ||
ARG GROUPNAME=app | ||
ARG UID=1000 | ||
ARG GID=1000 | ||
RUN groupadd -g $GID $GROUPNAME \ | ||
&& useradd -m -u $UID -g $GID $USERNAME | ||
|
||
# Add to download Composer packages from dist. | ||
RUN apt-get update && apt-get install -y unzip | ||
|
||
# Add to install symfony/panther. | ||
RUN apt-get update \ | ||
&& apt-get install -y \ | ||
libzip-dev \ | ||
zip \ | ||
&& docker-php-ext-install zip | ||
|
||
# Add to measure code coverage. | ||
RUN pecl install xdebug \ | ||
&& docker-php-ext-enable xdebug | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y chromium-driver | ||
|
||
COPY --from=composer /usr/bin/composer /usr/bin/composer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
parameters: | ||
level: max | ||
paths: | ||
- . | ||
- .php-cs-fixer.dist.php | ||
excludePaths: | ||
- vendor | ||
- vendor-bin | ||
bootstrapFiles: | ||
- vendor-bin/php-cs-fixer/vendor/autoload.php | ||
treatPhpDocTypesAsCertain: false | ||
reportUnmatchedIgnoredErrors: false | ||
|
||
# vim: set ft=yaml: |
Oops, something went wrong.