Skip to content

Commit

Permalink
feat(repo): running the sdk tests on main build (#4245)
Browse files Browse the repository at this point in the history
Fixes future failures in the SDK spec test monitor.

## Checklist

- [x] Title matches [Winglang's style guide](https://www.winglang.io/contributing/start-here/pull_requests#how-are-pull-request-titles-formatted)
- [x] Description explains motivation and solution
- [ ] Tests added (always)
- [ ] Docs updated (only required for features)
- [ ] Added `pr/e2e-full` label if this feature requires end-to-end testing

*By submitting this pull request, I confirm that my contribution is made under the terms of the [Wing Cloud Contribution License](https://github.com/winglang/wing/blob/main/CONTRIBUTION_LICENSE.md)*.
  • Loading branch information
tsuf239 authored Sep 27, 2023
1 parent 380c161 commit d6fb4d0
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 15 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,13 @@ jobs:
name: ${{ steps.diff.outputs.diff_name }}
path: ${{ steps.diff.outputs.diff_name }}

aws-sdk-spec-test:
needs:
- build
if: github.event_name == 'push'
uses: ./.github/workflows/tf-aws-test.yml
secrets: inherit

console-preview:
name: "Console Preview"
runs-on: ubuntu-latest
Expand Down Expand Up @@ -301,13 +308,13 @@ jobs:
flyctl deploy . --config ./apps/wing-console/console/app/preview/fly.toml --app "$APP_NAME" --image-label latest --vm-memory 512 --strategy immediate
flyctl scale count 1 --yes --app "$APP_NAME"
echo "deploytime=$(TZ=UTC date +'%Y-%m-%d %H:%M')" >> $GITHUB_OUTPUT
- name: Post preview comment
uses: thollander/actions-comment-pull-request@v2
with:
message: |
Console preview environment is available at https://${{env.APP_NAME}}.fly.dev :rocket:
*Updated (UTC): ${{steps.deploy-fly.outputs.deploytime }}*
comment_tag: Console preview environment
GITHUB_TOKEN: ${{secrets.PROJEN_GITHUB_TOKEN}}
Expand All @@ -321,6 +328,7 @@ jobs:
- e2e-test
- benchmark
- test
- aws-sdk-spec-test
steps:
- name: Check failure
if: needs.build.result == 'failure' || needs.e2e-test.result == 'failure' || needs.benchmark.result == 'failure' || needs.test.result == 'failure'
Expand Down
54 changes: 41 additions & 13 deletions .github/workflows/tf-aws-test.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,31 @@
name: SDK Spec AWS Tests
on:
release:
types:
- published
workflow_call: {}
workflow_dispatch: {}

env:
AWS_REGION: "us-east-1"
NODE_VERSION: "18.16.0"
# this variable indicates wheater to use wing cli from a local version (using the current repo code)
# or use the latest remote npm version
LOCAL_BUILD: ${{ github.workflow == 'build'}}

jobs:
setup:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Get list of directories
- name: Get list of directories and save them to the output
id: setdirs
shell: bash
run: |
dirs=$(ls -d examples/tests/sdk_tests/*/ | sed 's/\/$//' | grep -v "external" | jq -R -s -c 'split("\n")[:-1]')
processed_dirs=$(echo "{ \"directory\": $dirs }" | jq -c '[ .directory[] | {directory: ., name: (split("/") | last)}]')
wrapped_dirs=$(echo "{ \"test\": $processed_dirs }" | jq -c .)
echo "DIRS=$wrapped_dirs" >> $GITHUB_ENV
- name: Pass environment variable to output
id: passenv
run: |
echo "::set-output name=dirs::$DIRS"
echo "dirs=$wrapped_dirs" >> $GITHUB_OUTPUT
outputs:
tests: ${{ steps.passenv.outputs.dirs }}
tests: ${{ steps.setdirs.outputs.dirs }}

test-tf-aws:
needs: setup
Expand All @@ -39,21 +37,44 @@ jobs:
steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Setup Node.js v18
uses: actions/setup-node@v3
with:
node-version: 18
node-version: ${{ env.NODE_VERSION }}

##################### install a local wing version #########################
- name: Download Dist Artifacts
if: ${{ env.LOCAL_BUILD == 'true' }}
uses: actions/download-artifact@v3
with:
name: dist
path: dist

- name: Install Wing from Dist
if: ${{ env.LOCAL_BUILD == 'true' }}
run: |
mkdir localwing
cd localwing
npm init --yes
npm install ../dist/*-[0-9]*.[0-9]*.[0-9]*.tgz
./node_modules/.bin/wing --version
#################### install a remote wing version ########################
- name: Install winglang globally
if: ${{ env.LOCAL_BUILD == 'false' }}
uses: nick-fields/retry@v2
with:
max_attempts: 3
retry_on: error
timeout_minutes: 5
command: npm install -g winglang
########################################################################
- name: Installing external js modules
run: |
cd examples/tests/sdk_tests
npm install
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
Expand All @@ -68,8 +89,15 @@ jobs:
with:
max_attempts: 3
retry_on: error
timeout_minutes: 20
command: wing test -t tf-aws ${{ matrix.test.directory }}/*.w
timeout_minutes: 30
command: |
if ${{ env.LOCAL_BUILD == 'false' }}
then
wing test -t tf-aws ${{ matrix.test.directory }}/*.w
else
./localwing/node_modules/.bin/wing test -t tf-aws ${{ matrix.test.directory }}/*.w
fi
- name: Output Terraform log
if: failure()
run: cat ${{ runner.workspace }}/terraform.log

0 comments on commit d6fb4d0

Please sign in to comment.