Skip to content

Commit

Permalink
Merge pull request #2 from scpwiki/deploy
Browse files Browse the repository at this point in the history
Update deployment for attribution-metadata
  • Loading branch information
emmiegit authored Nov 22, 2023
2 parents 2453dae + 3db5368 commit 34d69ea
Show file tree
Hide file tree
Showing 19 changed files with 79 additions and 35 deletions.
21 changes: 9 additions & 12 deletions .github/workflows/check.yaml → .github/workflows/api-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@ name: 'Rust Build'
on:
push:
paths:
- '.github/workflows/check.yaml'
- 'Cargo.toml'
- 'Cargo.lock'
- 'src/**'
- 'build.rs'
- '.github/workflows/api-check.yaml'
- 'api/**'

jobs:
build:
Expand All @@ -30,11 +27,11 @@ jobs:
path: |
~/.cargo/registry
~/.cargo/git
./target
key: ${{ runner.os }}-rust-${{ hashFiles('Cargo.toml') }}
./api/target
key: ${{ runner.os }}-rust-${{ hashFiles('api/Cargo.toml') }}

- name: Build
run: cargo build
run: cd api && cargo build

clippy_lint:
name: Lint
Expand All @@ -59,11 +56,11 @@ jobs:
path: |
~/.cargo/registry
~/.cargo/git
./target
key: ${{ runner.os }}-rust-lint-${{ hashFiles('Cargo.toml') }}
./api/target
key: ${{ runner.os }}-rust-lint-${{ hashFiles('api/Cargo.toml') }}

- name: Rustfmt
run: cargo fmt --all -- --check
run: cd api && cargo fmt --all -- --check

- name: Clippy
run: cargo clippy
run: cd api && cargo clippy
32 changes: 32 additions & 0 deletions .github/workflows/web-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: 'Web Build'

on:
push:
paths:
- '.github/workflows/web-check.yaml'
- 'web/**'

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Node.js Setup
uses: actions/setup-node@v3
with:
node-version: '20.x'

- name: NPM Dependencies
run: cd web && npm ci

- name: NPM Cache
uses: actions/cache@v2
with:
path: ./node_modules
key: ${{ runner.os }}-node-${{ hashFiles('web/package.json') }}

- name: Build app
run: cd web && npm run build
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,21 @@ jobs:
- name: Setup Pages
uses: actions/configure-pages@v3

- name: Node.js Setup
uses: actions/setup-node@v3
with:
node-version: '20.x'

- name: NPM Dependencies
run: cd web && npm ci

- name: Build app
run: cd web && npm run build

- name: Upload artifact
uses: actions/upload-pages-artifact@v2
with:
path: web
path: web/dist

- name: Deploy to GitHub Pages
id: deployment
Expand Down
18 changes: 2 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,9 @@ A service which stores information regarding authorship (attribution) of SCP Wik

Because Wikidot does not recognize authorship beyond page creation, this has been a longstanding issue that SCP Wiki branches and sister sites have solved through the use of [attribution-metadata](https://scpwiki.com/attribution-metadata). This was previously a page on the Wikidot site which simply had a table with all the data on it, stored in wikitext. However, this means it is also subject to Wikidot page limitations, and when we passed that limit, it was clear that spending the time on a proper, better solution was the way to go.

This is that service. It stores all the attribution data in AWS DynamoDB, and handles requests without a permanent server using AWS Lambda.
This is that service. Defined in `api/`, this process stores all the attribution data in AWS DynamoDB, and handles requests without a permanent server using AWS Lambda.

### Deployment

Locally, you can verify that your code builds in the usual way:
```
cargo check
```

The most convenient way to produce artifacts that can be deployed to Lambda is using the [AWS Lambda Rust Runtime](https://github.com/awslabs/aws-lambda-rust-runtime). Using the `cargo lambda` subcommand:
```
cargo lambda build --release --arm64 --output-format zip
```

We target the ARM architecture because we are not using anything specific to x64, and ARM is cheaper and generally more power-efficient.

The resultant ZIP file (found in `target/lambda/attribution-metadata`) can be uploaded to Lambda via the [console](https://us-east-2.console.aws.amazon.com/lambda/home?region=us-east-2#/functions/AttributionMetadataService).
There is a corresponding web frontend, located in `web/`, which provides a convenient way of interacting with this service. However, any REST client can communicate with this service, for instance as part of automated checks or updates.

### License

Expand Down
File renamed without changes.
File renamed without changes.
19 changes: 19 additions & 0 deletions api/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## attribution-metadata API

This is the backend Lambda service which serves attribution-metadata requests, reading and writing the data from DynamoDB.

### Deployment

Locally, you can verify that your code builds in the usual way:
```
cargo check
```

The most convenient way to produce artifacts that can be deployed to Lambda is using the [AWS Lambda Rust Runtime](https://github.com/awslabs/aws-lambda-rust-runtime). Using the `cargo lambda` subcommand:
```
cargo lambda build --release --arm64 --output-format zip
```

We target the ARM architecture because we are not using anything specific to x64, and ARM is cheaper and generally more power-efficient.

The resultant ZIP file (found in `target/lambda/attribution-metadata`) can be uploaded to Lambda via the [console](https://us-east-2.console.aws.amazon.com/lambda/home?region=us-east-2#/functions/AttributionMetadataService).
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion web/LICENSE.md

This file was deleted.

10 changes: 5 additions & 5 deletions web/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
## attribution-metadata web
## attribution-metadata Web

This is a web UI for interfacing with the `attribution-metadata` Lambda service. It enables users to interact with the API in a user-friendly way, via their browser.

### Internationalization

This application supports translating into other languages. Simply add a corresponding list of translation strings within the `TRANSLATIONS` block in `src/util/i18n.ts`, connected with the language code. Then, on load, specifying the language code results in that language being loaded in the UI.

### Deployment

First, ensure dependencies are up-to-date:
Expand All @@ -21,10 +25,6 @@ npm run build

You can also use `bun` for these steps instead of `npm`.

### License

Available under the terms of the MIT License.

### Special Thanks

Thanks to smlt for contributing the initial version of this web frontend.

0 comments on commit 34d69ea

Please sign in to comment.