Skip to content

Test

Test #27

Workflow file for this run

# Run the test suite after the Docker image is successfully built.
#
# Test locally:
#
# # https://github.com/settings/tokens
# # https://github.com/nektos/act
# GITHUB_TOKEN="..."
# echo $GITHUB_TOKEN | docker login ghcr.io -u evazion --password-stdin
# ./act -s GITHUB_TOKEN=$GITHUB_TOKEN -j test -v --artifact-server-path tmp/artifacts
name: Test
# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#permissions
permissions: read-all
on:
# https://docs.github.com/en/actions/reference/events-that-trigger-workflows#workflow_run
workflow_run:
workflows: ["Docker Build"]
types: [completed]
workflow_dispatch:
inputs:
debug_enabled:
description: "Run the workflow with remote debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)"
required: false
default: false
defaults:
run:
working-directory: /danbooru
jobs:
test:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
# Don't run the test suite multiple times for the same commit.
concurrency: "test-${{ github.sha }}"
runs-on: ubuntu-latest
container:
image: ghcr.io/aibooruorg/aibooru:${{ github.sha }}
options: --user root
env:
HOME: /root
RAILS_ENV: test
PARALLEL_WORKERS: 8 # number of parallel tests to run
RUBYOPT: -W0 # silence ruby warnings
VIPS_WARNING: 0 # silence libvips warnings
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
DATABASE_URL: postgresql://danbooru:danbooru@postgres/danbooru
DANBOORU_SECRET_KEY_BASE: 1234
DANBOORU_PIXIV_PHPSESSID: ${{ secrets.DANBOORU_PIXIV_PHPSESSID }}
DANBOORU_NIJIE_LOGIN: ${{ secrets.DANBOORU_NIJIE_LOGIN }}
DANBOORU_NIJIE_PASSWORD: ${{ secrets.DANBOORU_NIJIE_PASSWORD }}
DANBOORU_NICO_SEIGA_USER_SESSION: ${{ secrets.DANBOORU_NICO_SEIGA_USER_SESSION }}
DANBOORU_TUMBLR_CONSUMER_KEY: ${{ secrets.DANBOORU_TUMBLR_CONSUMER_KEY }}
DANBOORU_DEVIANTART_CLIENT_ID: ${{ secrets.DANBOORU_DEVIANTART_CLIENT_ID }}
DANBOORU_DEVIANTART_CLIENT_SECRET: ${{ secrets.DANBOORU_DEVIANTART_CLIENT_SECRET }}
DANBOORU_PAWOO_ACCESS_TOKEN: ${{ secrets.DANBOORU_PAWOO_ACCESS_TOKEN }}
DANBOORU_BARAAG_ACCESS_TOKEN: ${{ secrets.DANBOORU_BARAAG_ACCESS_TOKEN }}
DANBOORU_FANTIA_SESSION_ID: ${{ secrets.DANBOORU_FANTIA_SESSION_ID }}
DANBOORU_FURAFFINITY_COOKIE_A: ${{ secrets.DANBOORU_FURAFFINITY_COOKIE_A }}
DANBOORU_FURAFFINITY_COOKIE_B: ${{ secrets.DANBOORU_FURAFFINITY_COOKIE_B }}
DANBOORU_TINAMI_SESSION_ID: ${{ secrets.DANBOORU_TINAMI_SESSION_ID }}
DANBOORU_DISCORD_WEBHOOK_ID: ${{ secrets.DANBOORU_DISCORD_WEBHOOK_ID }}
DANBOORU_DISCORD_WEBHOOK_SECRET: ${{ secrets.DANBOORU_DISCORD_WEBHOOK_SECRET }}
DANBOORU_RAKISMET_KEY: ${{ secrets.DANBOORU_RAKISMET_KEY }}
DANBOORU_RAKISMET_URL: ${{ secrets.DANBOORU_RAKISMET_URL }}
DANBOORU_IP_REGISTRY_API_KEY: ${{ secrets.DANBOORU_IP_REGISTRY_API_KEY }}
DANBOORU_GOOGLE_CLOUD_CREDENTIALS: ${{ secrets.DANBOORU_GOOGLE_CLOUD_CREDENTIALS }}
services:
postgres:
image: ghcr.io/danbooru/postgres:14.0
env:
POSTGRES_USER: danbooru
POSTGRES_PASSWORD: danbooru
options: >-
--mount type=tmpfs,destination=/var/lib/postgresql/data
steps:
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
timeout-minutes: 20
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled }}
with:
limit-access-to-actor: true
sudo: false
- name: Prepare database
run: |
bin/rails db:test:prepare
- name: Run tests
run: |
bin/rails test
- name: Upload test results
uses: actions/upload-artifact@v3
if: always()
with:
name: test-results
path: |
/tmp/html-test-results/index.html
/tmp/junit-test-results/TEST-*.xml
- name: Publish test results
if: always()
run: |
bin/github-print-test-results /tmp/junit-test-results/TEST-*.xml