Skip to content

Commit a7d412d

Browse files
authored
Feat/create issue v2 buttondown (#102)
* chore: scaffolding * feat: starting to add logic * feat: buttondown client and refactoring * chore: refactoring and simplification * chore: semi-working version * chore: first working version * feat: updated the fetch issue number function * feat: full migration to buttondown * fix: broken test
1 parent 6e5b385 commit a7d412d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+3268
-3056
lines changed

Cargo.lock

Lines changed: 608 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ members = [
55
"functions/fetch-issue-number",
66
"functions/fetch-quote",
77
"functions/fetch-sponsor",
8+
"functions/create-issue",
89
"shared",
910
]

functions/create-issue/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
target

functions/create-issue/Cargo.toml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
[package]
2+
name = "create-issue"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[dependencies]
7+
serde = { version = "1", features = ["derive"] }
8+
serde_json = "1"
9+
10+
lambda_runtime = "0.13.0"
11+
tokio = { version = "1", features = ["macros"] }
12+
13+
# Date/time handling
14+
chrono = { version = "0.4", features = ["serde"] }
15+
chrono-tz = "0.10"
16+
17+
# HTTP requests (with rustls for Lambda compatibility)
18+
reqwest = { version = "0.12", features = [
19+
"json",
20+
"rustls-tls",
21+
], default-features = false }
22+
23+
# Template engine
24+
tera = "1"
25+
26+
# Environment variables and error handling
27+
anyhow = "1"

functions/create-issue/README.md

Lines changed: 50 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,52 @@
1-
## How to update the base template
1+
# Introduction
22

3-
If you want to update the base template this is the process (unfortunately Mailchimp makes it a bit tricky):
3+
create-issuev2 is a Rust project that implements an AWS Lambda function in Rust.
44

5-
- Update the file `functions/create-issue/templates/newsletter.njk` and apply the desired changes
6-
- Run the tests with `node_modules/.bin/vitest run functions/create-issue/ -u` (from the root of the project)
7-
- Now the file `functions/create-issue/__tests__/__snapshots__/template.html` is up to date. Copy its code.
8-
- In Mailchimp edit the saved template and paste the code
9-
- Check that the preview renders as expected and save
5+
## Prerequisites
6+
7+
- [Rust](https://www.rust-lang.org/tools/install)
8+
- [Cargo Lambda](https://www.cargo-lambda.info/guide/installation.html)
9+
10+
## Building
11+
12+
To build the project for production, run `cargo lambda build --release`. Remove the `--release` flag to build for development.
13+
14+
Read more about building your lambda function in [the Cargo Lambda documentation](https://www.cargo-lambda.info/commands/build.html).
15+
16+
## Testing
17+
18+
You can run regular Rust unit tests with `cargo test`.
19+
20+
If you want to run integration tests locally, you can use the `cargo lambda watch` and `cargo lambda invoke` commands to do it.
21+
22+
First, run `cargo lambda watch` to start a local server. When you make changes to the code, the server will automatically restart.
23+
24+
Second, you'll need a way to pass the event data to the lambda function.
25+
26+
You can use the existent [event payloads](https://github.com/awslabs/aws-lambda-rust-runtime/tree/main/lambda-events/src/fixtures) in the Rust Runtime repository if your lambda function is using one of the supported event types.
27+
28+
You can use those examples directly with the `--data-example` flag, where the value is the name of the file in the [lambda-events](https://github.com/awslabs/aws-lambda-rust-runtime/tree/main/lambda-events/src/fixtures) repository without the `example_` prefix and the `.json` extension.
29+
30+
```bash
31+
cargo lambda invoke --data-example apigw-request
32+
```
33+
34+
For generic events, where you define the event data structure, you can create a JSON file with the data you want to test with. For example:
35+
36+
```json
37+
{
38+
"command": "test"
39+
}
40+
```
41+
42+
Then, run `cargo lambda invoke --data-file ./data.json` to invoke the function with the data in `data.json`.
43+
44+
45+
Read more about running the local server in [the Cargo Lambda documentation for the `watch` command](https://www.cargo-lambda.info/commands/watch.html).
46+
Read more about invoking the function in [the Cargo Lambda documentation for the `invoke` command](https://www.cargo-lambda.info/commands/invoke.html).
47+
48+
## Deploying
49+
50+
To deploy the project, run `cargo lambda deploy`. This will create an IAM role and a Lambda function in your AWS account.
51+
52+
Read more about deploying your lambda function in [the Cargo Lambda documentation](https://www.cargo-lambda.info/commands/deploy.html).

functions/create-issue/__tests__/__snapshots__/intro.html

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)