From 042900386310a384e1d085f861120370582078c3 Mon Sep 17 00:00:00 2001 From: Jakob Gillich Date: Sun, 23 Aug 2020 21:27:02 +0200 Subject: [PATCH] Auto publish docs --- .github/workflows/docker.yaml | 22 --------- .github/workflows/publish.yaml | 48 +++++++++++++++++++ .gitignore | 1 + README.md | 10 ++-- build.sbt | 11 +++-- src/main/resources/application.conf | 2 + .../psforever/objects/avatar/Cosmetic.scala | 7 +-- 7 files changed, 65 insertions(+), 36 deletions(-) delete mode 100644 .github/workflows/docker.yaml create mode 100644 .github/workflows/publish.yaml diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml deleted file mode 100644 index c8ca55a05..000000000 --- a/.github/workflows/docker.yaml +++ /dev/null @@ -1,22 +0,0 @@ -name: Docker Image -on: [push] -jobs: - docker: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Inject slug/short variables - uses: rlespinasse/github-slug-action@v2.x - - name: Set variables - run: | - echo "::set-env name=REPOSITORY::$(echo $GITHUB_REPOSITORY | tr '[A-Z]' '[a-z]')" - - name: Build and push Docker image - uses: docker/build-push-action@v1.1.0 - with: - username: ${{ github.actor }} - password: ${{ github.token }} - registry: docker.pkg.github.com - repository: ${{ env.REPOSITORY }}/server - tag_with_sha: true - tag_with_ref: true \ No newline at end of file diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 000000000..3cd35db58 --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,48 @@ +name: Publish +on: [push] +jobs: + docs: + if: github.ref == 'refs/heads/master' + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Cache SBT + uses: actions/cache@v2 + with: + path: | + ~/.ivy2/cache + ~/.sbt + key: ${{ runner.os }}-sbt-${{ hashFiles('**/build.sbt') }} + - name: Checkout + uses: actions/checkout@v2 + - name: Setup Scala + uses: olafurpg/setup-scala@v5 + - name: Build docs + run: sbt docs/unidoc + - name: Deploy to GitHub Pages + uses: JamesIves/github-pages-deploy-action@3.5.9 + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BRANCH: gh-pages + FOLDER: docs/target/scala-2.13/unidoc + + docker: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Inject slug/short variables + uses: rlespinasse/github-slug-action@v2.x + - name: Set variables + run: | + echo "::set-env name=REPOSITORY::$(echo $GITHUB_REPOSITORY | tr '[A-Z]' '[a-z]')" + - name: Build and push Docker image + uses: docker/build-push-action@v1.1.0 + with: + username: ${{ github.actor }} + password: ${{ github.token }} + registry: docker.pkg.github.com + repository: ${{ env.REPOSITORY }}/server + tag_with_sha: true + tag_with_ref: true \ No newline at end of file diff --git a/.gitignore b/.gitignore index e2bdb34de..bef6a5da0 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ out/ .bloop .metals project/metals.sbt +/docs # User configs config/psforever.conf diff --git a/README.md b/README.md index 515e3639d..207863599 100644 --- a/README.md +++ b/README.md @@ -112,14 +112,12 @@ To get started using pgAdmin, run the binary. This will start the pgAdmin server with the interface. Upon first run, enter your connection details that you created during the PostgreSQL installation. When connected, right click the "Databases" menu -> Create... -> Database: psforever -> Save. Next, right click on the newly created database (psforever) -> Query Tool... -> Copy and paste the commands below -> Hit the "Play/Run" button. -The user should be created and granted the right permissions on all future objects. +The user should be created and made owner of the database. ```sql CREATE USER psforever; ALTER USER psforever WITH PASSWORD 'psforever'; -ALTER DEFAULT PRIVILEGES IN SCHEMA PUBLIC GRANT ALL ON TABLES TO psforever; -ALTER DEFAULT PRIVILEGES IN SCHEMA PUBLIC GRANT ALL ON SEQUENCES TO psforever; -ALTER DEFAULT PRIVILEGES IN SCHEMA PUBLIC GRANT ALL ON FUNCTIONS TO psforever; +ALTER TABLE psforever OWNER TO psforever; ``` **NOTE:** applying default privileges _after_ importing the schema will not apply them to existing objects. To fix this, *you must drop all objects and try again or apply permissions manually using the Query Tool / `psql`. @@ -194,9 +192,9 @@ some helper scripts. Run the correct file for your platform (.BAT for Windows an ### Generating Documentation -Using sbt, you can generate documentation for both the common and pslogin projects using `sbt unidoc`. +Using sbt, you can generate documentation all projects using `sbt docs/unidoc`. -Current documentation is available at [https://psforever.github.io/docs/master/index.html](https://psforever.github.io/docs/master/index.html) +Current documentation is available at [https://jgillich.github.io/PSF-LoginServer/net/psforever/index.html](https://jgillich.github.io/PSF-LoginServer/net/psforever/index.html) ## Tools diff --git a/build.sbt b/build.sbt index ee8f239e4..9273e9791 100644 --- a/build.sbt +++ b/build.sbt @@ -27,13 +27,10 @@ lazy val psforeverSettings = Seq( // scaladoc flags: https://github.com/scala/scala/blob/2.11.x/src/scaladoc/scala/tools/nsc/doc/Settings.scala scalacOptions in (Compile, doc) ++= Seq( "-groups", - "-implicits", "-doc-title", "PSF-LoginServer - ", "-doc-version", "master", - "-doc-footer", - "Copyright PSForever", // For non unidoc builds, you may need bd.getName before the template parameter "-doc-source-url", "https://github.com/psforever/PSF-LoginServer/blob/master/€{FILE_PATH}.scala", @@ -134,3 +131,11 @@ lazy val decodePackets = (project in file("tools/decode-packets")) // Special test configuration for really quiet tests (used in CI) lazy val QuietTest = config("quiet") extend Test + +lazy val docs = (project in file("docs")) + .settings(psforeverSettings: _*) + .enablePlugins(ScalaUnidocPlugin) + .settings( + name := "psforever" + ) + .aggregate(psforever, server, decodePackets) diff --git a/src/main/resources/application.conf b/src/main/resources/application.conf index 3f923b3b7..b307db803 100644 --- a/src/main/resources/application.conf +++ b/src/main/resources/application.conf @@ -39,6 +39,8 @@ admin { } # Database configuration +# Full reference: https://github.com/jasync-sql/jasync-sql/wiki/Configuring-and-Managing-Connections +# https://github.com/getquill/quill/blob/master/quill-jasync/src/main/scala/io/getquill/context/jasync/JAsyncContextConfig.scala database { # The hostname of the PostgreSQL server. host = localhost diff --git a/src/main/scala/net/psforever/objects/avatar/Cosmetic.scala b/src/main/scala/net/psforever/objects/avatar/Cosmetic.scala index 8d980fe0d..146c61004 100644 --- a/src/main/scala/net/psforever/objects/avatar/Cosmetic.scala +++ b/src/main/scala/net/psforever/objects/avatar/Cosmetic.scala @@ -49,11 +49,8 @@ case object Cosmetic extends IntEnum[Cosmetic] { */ def valuesToAttributeValue(values: Set[Cosmetic]): Long = { values.foldLeft(1) { - case (sum, NoHelmet) => sum - 1 - case (sum, BrimmedCap) => sum + 2 - case (sum, Sunglasses) => sum + 4 - case (sum, Earpiece) => sum + 8 - case (sum, Beret) => sum + 16 + case (sum, NoHelmet) => sum - NoHelmet.value + case (sum, entry) => sum + entry.value } }