From 267406e3b0176f97922ebaa04c4e4971dfe56a95 Mon Sep 17 00:00:00 2001 From: emerging-tech-cdk-constructs-bot <146136861+emerging-tech-cdk-constructs-bot@users.noreply.github.com> Date: Mon, 3 Jun 2024 19:19:30 -0700 Subject: [PATCH] Trial (#16) * Update direct.yml --------- Co-authored-by: Scott Schreckengaust --- .github/workflows/direct.yml | 124 ++++++++++++++++++++++++++++++++--- 1 file changed, 115 insertions(+), 9 deletions(-) diff --git a/.github/workflows/direct.yml b/.github/workflows/direct.yml index 8afbdab..f545345 100644 --- a/.github/workflows/direct.yml +++ b/.github/workflows/direct.yml @@ -9,6 +9,10 @@ on: type: string required: true default: '0' + branchToCheckout: + type: string + required: true + default: 'main' jobs: build: runs-on: ubuntu-latest @@ -24,14 +28,116 @@ jobs: steps: - uses: actions/checkout@v4 with: - repository: 'https://github.com/awslabs/generative-ai-cdk-constructs' - - name: Get the PR + repository: 'awslabs/generative-ai-cdk-constructs' + - name: Get the PR and test mergeability if: fromJSON(inputs.pullRequestNumber) > 0 run: |- - echo "yes, there is a PR to find" - gh pr checkout ${{ inputs.pullRequestNumber }} - - name: Where are we - run: |- - git merge main - git branch - git diff main..HEAD + gh pr checkout ${{ inputs.pullRequestNumber }}; + git merge `gh pr view ${{ inputs.pullRequestNumber }} --json baseRefName | jq -r '.baseRefName'` + echo "::group::Git Differences" + git diff `gh pr view ${{ inputs.pullRequestNumber }} --json baseRefName | jq -r '.baseRefName'`..HEAD + echo "::endgroup::" + - uses: actions/setup-node@v4 + with: + node-version: '20.x' + cache: 'yarn' + cache-dependency-path: 'yarn.lock' + - run: |- + npm install -g aws-cdk + npx projen install + npx projen default + npx projen pre-compile + npx projen compile + npx projen post-compile + npx projen package-all + ls -lR ./dist/ + - name: package artifacts + uses: actions/upload-artifact@v4 + with: + name: dist + path: | + dist + samples: + runs-on: ubuntu-latest + needs: build + defaults: + run: + working-directory: samples/python-samples + env: + GH_TOKEN: ${{ github.token }} + pullRequestNumber: ${{ inputs.pullRequestNumber }} + externalId: ${{ inputs.externalId }} + permissions: + id-token: write + contents: read + checks: write + pull-requests: read + steps: + - uses: actions/checkout@v4 + with: + repository: 'aws-samples/generative-ai-cdk-constructs-samples' + ref: "${{ inputs.branchToCheckout }}" + - name: Download package + uses: actions/download-artifact@v4 + with: + name: dist + path: samples/python-samples/dist + - run: |- + ls -l; + cat requirements.txt | sed -e 's/^cdklabs\.generative-ai-cdk-constructs.*$/file\:\.\/dist\/python\/cdklabs\.generative_ai_cdk_constructs-0\.0\.0-py3-none-any\.whl/g' > requirements-local.txt + cat requirements-local.txt; + - uses: actions/setup-node@v4 + with: + node-version: '20.x' + - run: |- + npm install -g aws-cdk + node --version + npm --version + cdk --version + - uses: actions/setup-python@v5 + with: + python-version: '3.11' + cache: 'pip' + cache-dependency-path: | + 'samples/python-samples/requirements.txt' + 'samples/python-samples/requirements-local.txt' + 'samples/python-samples/requirements-dev.txt' + - run: |- + python -m venv .venv + source .venv/bin/activate + pip install -r requirements-local.txt + pip install -r requirements-dev.txt + - name: package artifacts + uses: actions/upload-artifact@v4 + with: + name: .venv + path: | + samples/python-samples/.venv/ + - uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: ${{ secrets.AWS_ROLE_ARN_TO_ASSUME }} + aws-region: ${{ vars.AWS_REGION }} + role-duration-seconds: 7200 + mask-aws-account-id: true + - run: |- + source .venv/bin/activate + cdk synthesize + cdk diff + cdk deploy --all --force --require-approval never --outputs-file cdk.out/deploy.json + - name: package artifacts + uses: actions/upload-artifact@v4 + with: + name: cdk.out + path: | + samples/python-samples/cdk.out/ + - run: |- + aws sts get-caller-identity + source .venv/bin/activate + pytest + - name: package artifacts + uses: actions/upload-artifact@v4 + with: + name: pytest + path: | + samples/python-samples/pytest-junit.xml +