Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 1 addition & 55 deletions .env.testing
Original file line number Diff line number Diff line change
Expand Up @@ -5,68 +5,14 @@ APP_DEBUG=true
APP_TIMEZONE=UTC
APP_URL=http://localhost

APP_LOCALE=en
APP_FALLBACK_LOCALE=en
APP_FAKER_LOCALE=en_US

APP_MAINTENANCE_DRIVER=file
# APP_MAINTENANCE_STORE=database

PHP_CLI_SERVER_WORKERS=4

BCRYPT_ROUNDS=12

LOG_CHANNEL=stack
LOG_STACK=single
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug

DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=computer_science_resources_testing
DB_USERNAME=root
DB_PASSWORD=password

SESSION_DRIVER=database
SESSION_LIFETIME=120
SESSION_ENCRYPT=false
SESSION_PATH=/
SESSION_DOMAIN=null

GITHUB_CLIENT_ID=Ov23liEEEW7WLTpaC688
GITHUB_CLIENT_SECRET=5a60158c32fc6ef2b6ac8d9771012a6ac4440eba

BROADCAST_CONNECTION=log
FILESYSTEM_DISK=local
QUEUE_CONNECTION=database

CACHE_STORE=database
CACHE_PREFIX=

MEMCACHED_HOST=127.0.0.1

REDIS_CLIENT=phpredis
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_MAILER=smtp
MAIL_HOST=mailpit
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS="hello@example.com"
MAIL_FROM_NAME="${APP_NAME}"

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false

VITE_APP_NAME="${APP_NAME}"
# TODO: Regenerate the keys for the google and github oauth

SAIL_XDEBUG_MODE=develop,debug,coverage
SSAIL_XDEBUG_CONFIG="discover_client_host=1 client_port=9003"
Expand Down
52 changes: 28 additions & 24 deletions .github/workflows/laravel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,9 @@ on:
workflow_dispatch:

jobs:
laravel-tests:
laravel-feature-tests:
runs-on: ubuntu-latest

# --------------------------------------------------------------
# Spin up a MySQL 8.0 container for testing
# --------------------------------------------------------------
services:
mysql:
image: mysql:8.0
Expand All @@ -28,19 +25,14 @@ jobs:
--health-timeout=5s
--health-retries=5

# --------------------------------------------------------------
# Define every environment variable manually
# --------------------------------------------------------------
env:
# Application settings
APP_NAME: "Computer Science Resources"
APP_ENV: testing
APP_KEY: base64:7aYe15aBsSh6a2ScVwj1JfYjQKUmz9Z5X/GSe64joHA=
APP_DEBUG: 'true'
APP_TIMEZONE: UTC
APP_URL: http://localhost

# Database settings (pointing to MySQL on localhost)
DB_CONNECTION: mysql
DB_HOST: 127.0.0.1
DB_PORT: 3306
Expand All @@ -52,43 +44,55 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

# --------------------------------------------------------------
# Set up PHP 8.3 + required extensions + Composer
# --------------------------------------------------------------
- name: Set up PHP & Composer
uses: shivammathur/setup-php@v2
with:
php-version: 8.3
extensions: mbstring, pdo, mysql, bcmath, tokenizer
tools: composer

- name: Cache Composer dependencies
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-

- name: Install Composer dependencies
run: composer install --no-interaction --prefer-dist

# --------------------------------------------------------------
# Generate a new application key (uses APP_KEY from `env:` above)
# --------------------------------------------------------------
- name: Generate app key
run: php artisan key:generate --ansi

# --------------------------------------------------------------
# Wait until MySQL is ready to accept connections
# --------------------------------------------------------------
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 20

- name: Cache node modules
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-

- name: Install NPM dependencies
run: npm ci

- name: Build assets
run: npm run build

- name: Wait for MySQL to be ready
run: |
echo "Waiting for MySQL to be ready..."
until mysqladmin ping -h 127.0.0.1 -P 3306 --silent; do
sleep 3
done

# --------------------------------------------------------------
# Run migrations (uses the `DB_` variables defined at the top)
# --------------------------------------------------------------
- name: Run database migrations
run: php artisan migrate --force

# --------------------------------------------------------------
# 9) Run all tests (feature + unit)
# --------------------------------------------------------------
- name: Run feature & unit tests
run: php artisan test
20 changes: 0 additions & 20 deletions app/Models/ResourceReviewSummary.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,4 @@ class ResourceReviewSummary extends Model
protected $fillable = ['computer_science_resource_id'];

protected $primaryKey = 'computer_science_resource_id';

protected $appends = ['average_reviews_score'];

/**
* Get the average reviews score.
*
* @return Attribute
*/
protected function averageReviewsScore(): Attribute
{
return Attribute::make(
get: function () {
if ($this->review_count === 0) {
return 0;
}

return round($this->overall_rating / $this->review_count, 2);
}
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ public function up(): void
$table->foreignIdFor(Comment::class, "root_comment_id")->nullable();
$table->foreignIdFor(Comment::class, "parent_comment_id")->nullable();
$table->foreignIdFor(User::class);

$table->text("content");

$table->smallInteger("depth")->default(1)->index();
// Only root comment uses this
$table->unsignedInteger("children_count")->default(0);
Expand Down
Loading