Skip to content

Commit

Permalink
Merge branch 'main' into tsuf/bucket-cors
Browse files Browse the repository at this point in the history
  • Loading branch information
monadabot authored Sep 10, 2024
2 parents 7ff3723 + 4f70083 commit 8d6cc55
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 31 deletions.
40 changes: 21 additions & 19 deletions docs/docs/08-guides/02-ci-cd.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
role-session-name: gh-actions-winglang # makes it easy to identify, e.g. in AWS Cloudtrail
aws-region: ${{ env.AWS_REGION }}
- name: Deploy Winglang App
uses: winglang/wing-github-action/actions/deploy@v0.1.0
uses: winglang/wing-github-action/actions/deploy@main
with:
entry: main.w
target: 'tf-aws'
Expand Down Expand Up @@ -109,7 +109,7 @@ jobs:
role-session-name: gh-actions-winglang
aws-region: ${{ env.AWS_REGION }}
- name: Terraform Plan
uses: winglang/wing-github-action/actions/pull-request-diff@v0.1.0
uses: winglang/wing-github-action/actions/pull-request-diff@main
with:
entry: main.w
target: 'tf-aws'
Expand All @@ -123,24 +123,26 @@ Most users will find using the Wing GitHub Action within GitHub Actions as the s
Refer to the following Github Action workflow as a template to define your customized workflow. For detailed instructions, please refer to the Github Actions [documentation](https://docs.github.com/en/actions).
#### Backend Plugin
#### Backend Platform
Add the following file to your application root directory as `plugin.s3-backend.js`. This will be used in the Github Action workflow during the `wing compile` step. Learn more about this in the [Terraform Backend guide](./01-terraform-backend.md)
Add the following file to your application root directory as `platform.s3-backend.js`. This will be used in the Github Action workflow during the `wing compile` step. Learn more about this in the [Terraform Backend guide](./01-terraform-backend.md)

```
// plugin.s3-backend.js
exports.postSynth = function(config) {
if (!process.env.TF_BACKEND_BUCKET) {throw new Error("env var TF_BACKEND_BUCKET not set")}
if (!process.env.TF_BACKEND_BUCKET_REGION) {throw new Error("env var TF_BACKEND_BUCKET_REGION not set")}
if (!process.env.TF_BACKEND_STATE_FILE) {throw new Error("env var TF_BACKEND_STATE_FILE not set")}
config.terraform.backend = {
s3: {
bucket: process.env.TF_BACKEND_BUCKET,
region: process.env.TF_BACKEND_BUCKET_REGION,
key: process.env.TF_BACKEND_STATE_FILE
// platform.s3-backend.js
exports.Platform = class TFBackend {
postSynth(config) {
if (!process.env.TF_BACKEND_BUCKET) {throw new Error("env var TF_BACKEND_BUCKET not set")}
if (!process.env.TF_BACKEND_BUCKET_REGION) {throw new Error("env var TF_BACKEND_BUCKET_REGION not set")}
if (!process.env.TF_BACKEND_STATE_FILE) {throw new Error("env var TF_BACKEND_STATE_FILE not set")}
config.terraform.backend = {
s3: {
bucket: process.env.TF_BACKEND_BUCKET,
region: process.env.TF_BACKEND_BUCKET_REGION,
key: process.env.TF_BACKEND_STATE_FILE
}
}
return config;
}
return config;
}
```
Expand Down Expand Up @@ -181,7 +183,7 @@ permissions:

env:
AWS_REGION: "us-east-1"
# The following values are used in the backend plugin which
# The following values are used in the backend platform which
# is used in the `wing compile` step
TF_BACKEND_BUCKET: "my-terraform-state-bucket-with-a-globally-unique-name"
TF_BACKEND_BUCKET_REGION: "us-east-1"
Expand All @@ -202,7 +204,7 @@ jobs:
- name: Install Dependencies
run: npm ci
- name: Compile
run: wing compile -t tf-aws --plugins=plugin.s3-backend.js main.w
run: wing compile -t tf-aws -t platform.s3-backend.js main.w
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
Expand All @@ -228,7 +230,7 @@ Consider adding Winglang simulator tests as an intermediate step in your workflo
- name: Run Tests
run: wing test main.w
- name: Compile
run: wing compile -t tf-aws --plugins=plugin.s3-backend.js main.w
run: wing compile -t tf-aws -t platform.s3-backend.js main.w
# ...
```
Expand All @@ -241,7 +243,7 @@ Consider integrating third-party Terraform analysis tools for more comprehensive
- name: Install Dependencies
run: npm ci
- name: Compile
run: wing compile -t tf-aws --plugins=plugin.s3-backend.js main.w
run: wing compile -t tf-aws -t platform.s3-backend.js main.w
- name: Check Terraform Config
run: cd ./target/main.tfaws && your-tf-tool
# ...
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"wing": "turbo compile -F winglang --output-logs=new-only && ./packages/winglang/bin/wing"
},
"volta": {
"node": "20.11.1",
"node": "20.17.0",
"pnpm": "8.15.1"
},
"packageManager": "[email protected]",
Expand Down
4 changes: 1 addition & 3 deletions packages/@winglang/wingc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,21 +84,19 @@ const WINGSDK_HTTP_MODULE: &'static str = "http";
const WINGSDK_MATH_MODULE: &'static str = "math";
const WINGSDK_AWS_MODULE: &'static str = "aws";
const WINGSDK_EXPECT_MODULE: &'static str = "expect";
const WINGSDK_REGEX_MODULE: &'static str = "regex";
const WINGSDK_FS_MODULE: &'static str = "fs";
const WINGSDK_SIM_MODULE: &'static str = "sim";
const WINGSDK_UI_MODULE: &'static str = "ui";

pub const UTIL_CLASS_NAME: &'static str = "Util";

const WINGSDK_BRINGABLE_MODULES: [&'static str; 10] = [
const WINGSDK_BRINGABLE_MODULES: [&'static str; 9] = [
WINGSDK_CLOUD_MODULE,
WINGSDK_UTIL_MODULE,
WINGSDK_HTTP_MODULE,
WINGSDK_MATH_MODULE,
WINGSDK_AWS_MODULE,
WINGSDK_EXPECT_MODULE,
WINGSDK_REGEX_MODULE,
WINGSDK_FS_MODULE,
WINGSDK_SIM_MODULE,
WINGSDK_UI_MODULE,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: libs/wingc/src/lsp/completions.rs
source: packages/@winglang/wingc/src/lsp/completions.rs
---
- label: aws
kind: 9
Expand All @@ -19,9 +19,6 @@ source: libs/wingc/src/lsp/completions.rs
- label: math
kind: 9
sortText: kk|math
- label: regex
kind: 9
sortText: kk|regex
- label: sim
kind: 9
sortText: kk|sim
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: libs/wingc/src/lsp/completions.rs
source: packages/@winglang/wingc/src/lsp/completions.rs
---
- label: aws
kind: 9
Expand All @@ -19,9 +19,6 @@ source: libs/wingc/src/lsp/completions.rs
- label: math
kind: 9
sortText: kk|math
- label: regex
kind: 9
sortText: kk|regex
- label: sim
kind: 9
sortText: kk|sim
Expand Down
6 changes: 6 additions & 0 deletions tests/invalid/bring.test.w
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@ bring ;
//^^^^^ Expected module specification (see https://www.winglang.io/docs/libraries)
bring c;
//^^^^^^ "c" is not a built-in module

bring regex;
//^ "Could not find a trusted library "@winglibs/regex" installed"

bring num;
//^ Could not find a trusted library "@winglibs/num" installed
14 changes: 14 additions & 0 deletions tools/hangar/__snapshots__/invalid.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,20 @@ error: Could not find a trusted library "@winglibs/c" installed. Did you mean to
| ^^^^^^^^


error: Could not find a trusted library "@winglibs/regex" installed. Did you mean to run \`npm i @winglibs/regex\`?
--> ../../../tests/invalid/bring.test.w:11:1
|
11 | bring regex;
| ^^^^^^^^^^^^


error: Could not find a trusted library "@winglibs/num" installed. Did you mean to run \`npm i @winglibs/num\`?
--> ../../../tests/invalid/bring.test.w:14:1
|
14 | bring num;
| ^^^^^^^^^^


error: Redundant bring of "std"
--> ../../../tests/invalid/bring.test.w:1:1
|
Expand Down

0 comments on commit 8d6cc55

Please sign in to comment.