Commit Graph

48 Commits

Author SHA1 Message Date
nonamethanks
8edd5dd810 Add furaffinity support 2022-04-27 03:47:59 +02:00
evazion
2b387bdc41 docker: add Docker image for ARM.
* Have CI build Docker images for both x86 and ARM.
* Add a `bin/rails danbooru:docker:build-arm` command for building a Docker image locally for ARM.

Usage:

* Test the image:

  docker run --rm -it --platform linux/arm64 ghcr.io/danbooru/danbooru bash

* Build the image:

  bin/rails danbooru:docker:build-arm

* Build the image by hand:

  git archive HEAD | docker buildx build - --platform linux/amd64 --build-arg SOURCE_COMMIT=$(git rev-parse HEAD) -t danbooru -f Dockerfile --load
2022-04-24 21:42:51 -05:00
evazion
7f58cfbe5e tinami: get the full image.
Support grabbing the full image for Tinami uploads, rather than the sample.

Getting the full image requires making a request like this:

    curl -X POST \
    -H 'Referer: https://www.tinami.com/' \
    -H 'Content-Type: application/x-www-form-urlencoded' \
    -H 'Cookie: Tinami2SESSID=<redacted>;' \
    --data-raw 'action_view_original=true&cont_id=1087268&ethna_csrf=<redacted>' \
    https://www.tinami.com/view/1087268

Then scraping the <img> tag from the resulting HTML page.

If the post has multiple images, then we need to scrape and pass the
`sub_id` of the image too.

Fixes #2818.
2022-03-19 23:22:09 -05:00
nonamethanks
a6549bc6fe Add Fantia support
Also fixes a regression in 74fdeef10c
that stopped mastodon urls from being given the right priority.
2022-03-10 17:43:32 +01:00
evazion
7b009cc893 nicoseiga: fix inability to login to nicoseiga.
NicoSeiga changed it so that on every login, you must enter a 2FA code
sent by email. This broke the NicoSeiga strategy. The fix is to just use
a static session cookie instead (and hope it doesn't expire, and isn't
tied to an IP).

The `nico_seiga_login` and `nico_seiga_password` config settings have
been removed from config/danbooru_default_config.rb and replaced by
`nico_seiga_user_session`. If you run your own Danbooru instance, you
will have to update your config file manually.
2022-02-22 12:23:01 -06:00
evazion
c8e4dceedb ci: use Postgres 14.0 for test suite. 2021-10-13 04:21:49 -05:00
evazion
5ef231e1dc ci: use tmpfs for test suite database.
Better fix for d128bb71b. Turns out /tmp isn't a tmpfs.
2021-10-01 17:52:53 -05:00
evazion
caa261e930 ci: fix tests running multiple times for same commit.
Fix the test suite running multiple times when pushing multiple branches
at once.
2021-10-01 17:48:19 -05:00
evazion
d128bb71b6 ci: use /tmp for test suite database.
Store the Postgres database for the test suite in /tmp to effectively
run it in a ramdisk and make the test suite run faster.
2021-09-30 08:24:51 -05:00
evazion
cc9d7b8349 Revert "ci: prevent running multiple Docker builds at once."
This reverts commit 9d62f71cd9.

This caused a problem where if you pushed multiple branches or tags at
once, for example to the betabooru and production branches, then the
Docker image would only get built for one branch. This led to deploys
not fetching the latest image.
2021-09-29 08:13:39 -05:00
evazion
9d62f71cd9 ci: prevent running multiple Docker builds at once. 2021-09-24 08:40:33 -05:00
evazion
259e3fde68 ci: fix issue with betabooru deploy workflow.
Just trigger on pushes to the betabooru branch instead of on the Docker
image being built. The workflow_run event keeps triggering on the master
branch even though it's supposed to only trigger on the betabooru
branch. This makes it fail because it doesn't have access to the secrets
in the betabooru environment.

This does mean the deploy will fail if the image hasn't been previously
built by a push to master first.
2021-09-22 12:33:42 -05:00
evazion
9b6c429d4c ci: automatically deploy betabooru on push.
Make it so that on every push to the `betabooru` branch, the latest
commit is automatically deployed to https://betabooru.donmai.us.
2021-09-22 09:31:26 -05:00
evazion
5af21f03de versions: default ARCHIVE_DATABASE_URL to DATABASE_URL.
Make it so that when ARCHIVE_DATABASE_URL isn't set, it defaults to
DATABASE_URL. In other words, if you don't have a separate archive
database configured, then default to using the main database for
post/pool versions.

Fixes an issue where running the test suite would fail if you didn't
explicitly set ARCHIVE_DATABASE_URL because it tried to use
`archive_test` as the post/pool versions database name.
2021-09-22 00:34:28 -05:00
evazion
3a0614bb55 db: recreate post versions and pool versions tables.
Add the post and pool versions tables back. Currently only used by the
test suite to make it easier to run. Not yet used for production.
2021-09-21 12:35:46 -05:00
evazion
96c5c346ad ci: allow triggering docker build workflow manually.
Add a `workflow_dispatch` so that it's possible it's possible to trigger
the Docker build workflow manually.

https://github.blog/changelog/2020-07-06-github-actions-manual-triggers-with-workflow_dispatch/
2021-09-18 21:34:28 -05:00
evazion
bc73d47643 Remove .github/stale.yml.
Unused.
2021-09-18 06:01:01 -05:00
evazion
020ed7b735 ci: don't tag short commit hash on Docker images.
Tagging both the long and the short commit hash on images creates too
much clutter in the Github UI.
2021-09-18 05:14:36 -05:00
evazion
52cf13dff1 ci: limit workflow permissions.
Make it so pull requests from outside contributors can't edit workflows
under .github/workflows/ without approval. Also limit workflows to the
minimum permissions necessary.
2021-09-18 04:37:00 -05:00
evazion
39fa2fe02d ci: split docker build workflow from test workflow.
Split up the Github workflow. Instead of one workflow with two jobs, one
to build the Docker image and one to test it, split it into two separate
workflows, one to build and one to test. This way if the Docker build
fails it doesn't try to run the tests, and if the tests fail it only
marks the test workflow as failed, not the entire workflow.

This is especially so the workflows page doesn't show everything as
failing just because the tests failed.

https://github.com/danbooru/danbooru/actions
2021-09-18 01:34:07 -05:00
evazion
291758ddb7 ci: push docker images to dockerhub too. 2021-09-07 06:49:19 -05:00
evazion
266192c599 ci: fix docker image not including git hash.
Fix the Docker image not including the git hash of the build. On
DockerHub we had to set it with a build hook, but now with Github we
set it as part of the build-push-action.
2021-09-07 06:34:50 -05:00
evazion
906eec190d ci: run tests inside docker
Run the tests using the Docker image we just built, instead of
installing everything manually and running the tests outside of Docker.
Ensures the Docker image we built really works.
2021-09-06 08:53:26 -05:00
evazion
661368bdcf ci: add github actions debugging with tmate
Usage is to run a workflow manually with debug_enabled on.

https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow#running-a-workflow
https://github.com/marketplace/actions/debugging-with-tmate
2021-09-06 04:19:52 -05:00
evazion
e240c92d6f github: update docker build workflow to use cache.
Update the Docker build workflow to use premade actions so we can cache
the build.

https://github.com/docker/setup-buildx-action
https://github.com/docker/login-action
https://github.com/docker/metadata-action
https://github.com/docker/build-push-action
2021-09-04 04:07:53 -05:00
evazion
8aa7608816 github: add docker build workflow action.
Add an action to build a Docker image and push it to the Github Packages
registry.
2021-09-03 23:23:00 -05:00
evazion
f235b72b3f Export public database dumps to BigQuery.
* Export daily public database dumps to BigQuery and Google Cloud Storage.
* Only data visible to anonymous users is exported. Some tables have
  null or missing fields because of this.
* The bans table is excluded because some bans have an expires_at
  timestamp set beyond year 9999, which BigQuery doesn't support.
* The favorites table is excluded because it's too slow to dump (it
  doesn't have an id index, which is needed by find_each).
* Version tables are excluded because dumping them every day is
  inefficient, streaming insertions should be used instead.

Links:

* https://console.cloud.google.com/bigquery?project=danbooru1
* https://console.cloud.google.com/storage/browser/danbooru_public
* https://storage.googleapis.com/danbooru_public/data/posts.json
2021-03-10 02:52:16 -06:00
evazion
b63d8207a9 forum: automatically post new forum posts to Discord. 2021-02-18 07:08:45 -06:00
evazion
013fd38175 tests: add baraag credentials to github CI. 2021-02-18 03:53:33 -06:00
evazion
39cc3ed5cf pixiv: fix API breakage.
Fix the Pixiv API no longer working by rewriting the Pixiv strategy to
use the Ajax API instead of the mobile API.

Before we could authenticate in the mobile API by using the OAuth 2.0
grant_type=password authentication flow. This no longer works. Now it
requires logging in through a HTML page, which is protected by Google
reCaptcha. This makes using the mobile API infeasible.

Instead we switch to the Ajax API, which only needs a PHPSESSID to
authenticate. This can be obtained by logging in manually and using the
devtools to extract the cookie.

This also temporarily removes support for Pixiv novels. This should be
moved to a separate source strategy.
2021-02-09 06:18:36 -06:00
evazion
9a0a988572 tests: fix test breakage in Github CI.
Fix tests not working in Github. They were failing because the latest
version of Webpack needs a version of Node newer than the version in
shipped Ubuntu 20.04.

Also fix the Docker build failing because of the system timezone
database not being installed in Ubuntu 20.10.
2021-02-05 03:40:16 -06:00
evazion
0713751e3c tests: fix user upgrades not being tested in CI. 2021-01-27 16:55:46 -06:00
evazion
e5f459bd52 ci: remove merge conflict notifier job.
Seems to be broken and it's not worth debugging.
2020-08-17 14:47:43 -05:00
evazion
136bb9d8ae ci: fix codecov.io uploader not working.
We need to check out the full repo so the codecov.io uploader can detect
the branch and commit hash.
2020-06-27 20:26:48 -05:00
evazion
09dff5b929 ci: track coverage with codecov.io instead of codeclimate.com.
Comparison:

* Codecov has a simpler integration and a better UI.
* Codeclimate tracks both linter warnings (Rubocop, ESLint) and code
  coverage, but its UI for code coverage is worse than Codecov's.
* Codeclimate doesn't support Simplecov 0.18 because Codeclimate doesn't
  support 0.18's new coverage format yet.
2020-06-27 13:01:35 -05:00
evazion
1d369f4574 ci: notify when a PR has a merge conflict.
Adds a "merge conflict" label and posts a comment when a PR has a merge
conflict. See https://github.com/Marr11317/ConflictAdviser#limitations.
2020-06-24 02:01:41 -05:00
evazion
440bbbb288 Update nokogiri gem.
Fix gem version conflicts described in 20abd8a5f. Nokogiri couldn't be
upgraded past 1.10.9 because 1.11.0 causes a build failure in Nokogumbo
2.0.2, but we couldn't stay on 1.10.9 either because it has a hard
requirement on Ruby <2.7 and we require Ruby >=2.7. This made `bundle
update` fail with a Gemfile conflict.

The fix is to disable libxml2 support when building Nokogumbo. Nokogumbo
wants to use the same version of libxml2 as Nokogiri, but Nokogiri
1.11.0 changed how it reports which version of libxml2 it's using, which
causes Nokogumbo's build to fail. Disabling libxml2 may reduce
performance of Nokogumbo ([1]).

While we're at it, we also make Nokogiri use the system version of
libxml2 instead of its own bundled version. Nokogiri really wants
us to use its own patched version of libxml2 instead of the system
version, but the patches it applies look relatively minor and don't seem
relevant to us ([2]). Using the system version reduces build time during CI.

This adds libxml2 and libxslt as OS-level dependencies of Danbooru. You
may need to do `sudo apt-get install libxml2-dev libxslt-dev` to install
these libraries after this commit.

[1]: https://github.com/rubys/nokogumbo#flavors-of-nokogumbo
[2]: https://github.com/sparklemotion/nokogiri/tree/master/patches/libxml2
2020-06-19 02:27:15 -05:00
evazion
52367c79e2 ci: upload code coverage even when tests fail. 2020-06-15 20:21:09 -05:00
evazion
4c56447d66 ci: add codecov.io integration. 2020-06-15 17:32:59 -05:00
evazion
107729e17f ci: enable codeclimate reporter debug output. 2020-06-15 17:21:41 -05:00
evazion
a615a28b1b ci: disable warnings during tests. 2020-06-15 16:45:37 -05:00
evazion
f60b184a12 ci: don't trigger twice on pull requests. 2020-06-15 16:45:37 -05:00
evazion
025e09ff7f tests: upload test coverage reports to code climate.
Downgrade simplecov to 0.17 because 0.18 is incompatible with code
climate. Ref: github.com codeclimate/test-reporter/issues/413
2020-06-11 15:35:15 -05:00
evazion
04c8c25976 tests: initialize pawoo credentials in github tests. 2020-06-10 22:49:28 -05:00
evazion
5919fa0ca1 tests: enable parallel tests. 2020-06-10 22:26:47 -05:00
evazion
5e63a7cf77 Add test workflow. 2020-06-10 17:52:13 -05:00
evazion
060a585e34 stale.yml: bump timeouts, change wontfix -> stale 2019-08-05 17:52:15 -05:00
Albert Yi
2db8e9814b add yml file for stale bot 2019-07-29 14:10:47 -07:00