-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into vscode-workspace
- Loading branch information
Showing
669 changed files
with
28,833 additions
and
14,831 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,8 +35,10 @@ jobs: | |
version: ${{ fromJson(steps.changelog.outputs.data).newVersion }} | ||
last-version: ${{ fromJson(steps.changelog.outputs.data).lastVersion }} | ||
changelog: ${{ fromJson(steps.changelog.outputs.data).changelog }} | ||
vscode-wing-changed: ${{ steps.git-diff-vscode-wing.outputs.diff }} | ||
|
||
vscode-wing-changed: ${{ fromJson(steps.turbo-diff.outputs.data)['vscode-wing#compile'].changes }} | ||
console-changed: ${{ fromJson(steps.turbo-diff.outputs.data)['@wingconsole/app#preview:fly'].changes }} | ||
e2e-changed: ${{ fromJson(steps.turbo-diff.outputs.data)['hangar#test'].changes }} | ||
bench-changed: ${{ fromJson(steps.turbo-diff.outputs.data)['hangar#bench'].changes }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
@@ -72,58 +74,34 @@ jobs: | |
- name: Install Dependencies | ||
run: pnpm install --frozen-lockfile | ||
|
||
- name: Derive appropriate SHAs for base and head | ||
id: shas | ||
uses: nrwl/nx-set-shas@v3 | ||
|
||
- name: Figure out what projects changed | ||
id: turbo-diff | ||
run: pnpm turbo-diff --startRef ${{ steps.shas.outputs.base }} --endRef ${{ steps.shas.outputs.head }} | ||
|
||
- name: Changelog Generation | ||
id: changelog | ||
env: | ||
GENERATE_VERSION: ${{ github.event_name != 'push' || github.repository != 'winglang/wing' }} | ||
run: pnpm changelog | ||
run: pnpm bump-pack | ||
|
||
- name: Build and Package | ||
run: pnpm package:ci | ||
env: | ||
SEGMENT_WRITE_KEY: ${{ secrets.SEGMENT_WRITE_KEY }} | ||
|
||
- name: Derive appropriate SHAs for base and head | ||
id: setSHAs | ||
uses: nrwl/nx-set-shas@v3 | ||
|
||
- name: Check git diff of VSCode Extension | ||
id: git-diff-vscode-wing | ||
run: | | ||
if git diff --quiet ${{ steps.setSHAs.outputs.base }} ${{ github.sha }} -- apps/vscode-wing; then | ||
echo "diff=false" >> "$GITHUB_OUTPUT" | ||
else | ||
echo "diff=true" >> "$GITHUB_OUTPUT" | ||
fi | ||
- name: Upload Artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: dist | ||
path: dist/* | ||
|
||
# Create patch to go from the PR head to the merge commit | ||
- name: Create git patch for merge | ||
if: github.event_name == 'pull_request' | ||
id: diff | ||
run: | | ||
git diff --binary --patch ${{ github.event.pull_request.head.sha }} ${{ github.sha }} > update.diff | ||
if [ -s update.diff ]; then | ||
echo "Diff found, creating a patch to apply later" | ||
cat update.diff | ||
echo "diff=true" >> $GITHUB_OUTPUT | ||
fi | ||
- name: Upload patch | ||
if: steps.diff.outputs.diff == 'true' | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: update.diff | ||
path: update.diff | ||
|
||
test: | ||
name: Test | ||
timeout-minutes: 30 | ||
timeout-minutes: 60 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
|
@@ -164,14 +142,7 @@ jobs: | |
|
||
- name: Create git patch | ||
id: diff | ||
run: | | ||
git add --all | ||
git diff --staged --binary --patch > build.diff | ||
if [ -s build.diff ]; then | ||
echo "Diff found, creating a patch to apply later" | ||
cat build.diff | ||
echo "diff=true" >> $GITHUB_OUTPUT | ||
fi | ||
run: scripts/create_patch.sh build.diff | ||
|
||
- name: Upload patch | ||
if: steps.diff.outputs.diff == 'true' | ||
|
@@ -182,6 +153,7 @@ jobs: | |
|
||
benchmark: | ||
name: Benchmark | ||
if: needs.build.outputs.bench-changed == 'true' || contains(github.event.pull_request.labels.*.name, '🧪 pr/e2e-full') | ||
runs-on: ubuntu-latest | ||
needs: | ||
- build | ||
|
@@ -227,6 +199,7 @@ jobs: | |
runs-on: "${{ matrix.runner }}-latest" | ||
needs: | ||
- build | ||
if: needs.build.outputs.e2e-changed == 'true' || contains(github.event.pull_request.labels.*.name, '🧪 pr/e2e-full') | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
|
@@ -282,13 +255,7 @@ jobs: | |
RAW_SHARD: ${{ matrix.shard }} | ||
run: | | ||
SHARD=$(echo $RAW_SHARD | sed 's/\//of/g') | ||
DIFF_NAME="e2e-$SHARD.diff" | ||
git add --all | ||
git diff --staged --binary --patch > $DIFF_NAME | ||
if [ -s $DIFF_NAME ]; then | ||
echo "diff=true" >> $GITHUB_OUTPUT | ||
echo "diff_name=$DIFF_NAME" >> $GITHUB_OUTPUT | ||
fi | ||
scripts/create_patch.sh "e2e-$SHARD.diff" | ||
- name: Upload mutation | ||
if: matrix.runner == 'ubuntu' && matrix.node == '18' && steps.diff.outputs.diff == 'true' | ||
|
@@ -297,26 +264,74 @@ jobs: | |
name: ${{ steps.diff.outputs.diff_name }} | ||
path: ${{ steps.diff.outputs.diff_name }} | ||
|
||
console-preview: | ||
name: "Console Preview" | ||
runs-on: ubuntu-latest | ||
needs: | ||
- build | ||
env: | ||
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} | ||
FLY_VERSION: "0.1.80" | ||
APP_NAME: wing-console-pr-${{github.event.number}} | ||
if: ${{ needs.build.outputs.console-changed == 'true' && github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && !startsWith(github.head_ref, 'mergify/merge-queue/') }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Download Dist Artifacts | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: dist | ||
path: dist | ||
|
||
- name: Install flyctl | ||
uses: superfly/flyctl-actions/[email protected] | ||
with: | ||
version: ${{ env.FLY_VERSION }} | ||
|
||
- name: Deploy to Fly.io | ||
id: deploy-fly | ||
run: | | ||
if ! flyctl status --app "$APP_NAME"; then | ||
pushd ./apps/wing-console/console/app/preview | ||
flyctl launch --no-deploy --copy-config --name "$APP_NAME" --image-label latest | ||
popd | ||
fi | ||
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}} | ||
|
||
quality-gate: | ||
name: Quality Gate | ||
runs-on: ubuntu-latest | ||
if: ${{ !cancelled() }} | ||
needs: | ||
- build | ||
- e2e-test | ||
- benchmark | ||
- test | ||
steps: | ||
- name: Check failure | ||
if: needs.build.result == 'failure' || needs.e2e-test.result == 'failure' || needs.benchmark.result == 'failure' || needs.test.result == 'failure' | ||
run: exit 1 | ||
- name: Download patches | ||
uses: actions/download-artifact@v3 | ||
- name: Check patches | ||
run: | | ||
PATCH_COUNT=0 | ||
for f in $(find ./*.diff/*.diff); do | ||
# Exclude update.diff since we don't want to fail if the PR is just not up to date | ||
if [ "$f" != "./update.diff/update.diff" ]; then | ||
PATCH_COUNT=$((PATCH_COUNT + 1)) | ||
cat $f | ||
fi | ||
PATCH_COUNT=$((PATCH_COUNT + 1)) | ||
cat $f | ||
done | ||
if [ $PATCH_COUNT -gt 0 ]; then | ||
echo "Found $PATCH_COUNT patches, build failed. A self-mutation should happen soon." | ||
|
@@ -327,7 +342,7 @@ jobs: | |
|
||
publish: | ||
name: Publish | ||
if: ${{ github.event_name == 'push' && github.repository == 'winglang/wing' && github.ref == 'refs/heads/main' }} | ||
if: ${{ !cancelled() && needs.quality-gate.result == 'success' && github.event_name == 'push' && github.repository == 'winglang/wing' && github.ref == 'refs/heads/main' }} | ||
needs: | ||
- quality-gate | ||
- build | ||
|
@@ -351,8 +366,8 @@ jobs: | |
env: | ||
PACKAGE_VERSION: ${{ needs.build.outputs.version }} | ||
run: | | ||
PACKAGES=("winglang-sdk" "winglang-compiler" "wingconsole-design-system" "wingconsole-ui" "wingconsole-server" "wingconsole-app") | ||
for PACKAGE in $PACKAGES; do | ||
PACKAGES=("winglang-sdk" "winglang-compiler" "wingconsole-design-system" "wingconsole-ui" "wingconsole-server" "wingconsole-app" "winglang") | ||
for PACKAGE in "${PACKAGES[@]}"; do | ||
npm publish "$PACKAGE-$PACKAGE_VERSION.tgz" --access public | ||
done | ||
|
@@ -374,7 +389,11 @@ jobs: | |
|
||
- name: Compute Checksums | ||
run: | | ||
mv ./benchmarks/* ./dist | ||
# if there is a ./benchmarks/report.json, move it to ./dist | ||
if [ -f ./benchmarks/report.json ]; then | ||
mv ./benchmarks/report.json ./dist | ||
fi | ||
cd dist | ||
echo '' >> ../CHANGELOG.md | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Delete Console Preview | ||
|
||
on: | ||
pull_request: | ||
types: | ||
- closed | ||
|
||
env: | ||
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} | ||
FLY_VERSION: "0.1.80" | ||
APP_NAME: wing-console-pr-${{github.event.number}} | ||
|
||
jobs: | ||
destroy: | ||
name: "Destroy" | ||
runs-on: ubuntu-latest | ||
if: ${{ github.event.pull_request.head.repo.full_name == github.repository && !startsWith(github.head_ref, 'mergify/merge-queue/') }} | ||
steps: | ||
- name: Install flyctl | ||
uses: superfly/flyctl-actions/[email protected] | ||
with: | ||
version: ${{env.FLY_VERSION}} | ||
|
||
- name: Delete preview environment | ||
run: | | ||
if flyctl status --app "$APP_NAME"; then | ||
flyctl apps destroy "$APP_NAME" -y | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,8 +21,7 @@ permissions: | |
jobs: | ||
mutate: | ||
runs-on: ubuntu-latest | ||
# Run if the workflow run is a pull request | ||
if: github.event.workflow_run.conclusion == 'failure' && (!contains(fromJSON('["main", "dev"]'), github.event.workflow_run.head_branch) || github.event.workflow_run.head_repository.fork) | ||
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'failure' && (!contains(fromJSON('["main", "dev"]'), github.event.workflow_run.head_branch) || github.event.workflow_run.head_repository.fork) | ||
steps: | ||
- name: Download artifacts | ||
id: download-artifacts | ||
|
@@ -57,48 +56,78 @@ jobs: | |
run: | | ||
git config --global core.hooksPath /dev/null | ||
- name: Update PR Branch | ||
uses: actions/github-script@v6 | ||
if: github.event.workflow_run.event == 'pull_request' && steps.download-artifacts.outputs.found_artifact == 'true' | ||
with: | ||
github-token: ${{ secrets.MUTATION_TOKEN }} | ||
script: | | ||
// use API to get the PR data since we can't rely on the context across forks | ||
const pulls = await github.rest.pulls.list({ | ||
per_page: 1, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
head: `${context.payload.workflow_run.head_repository.full_name}:${context.payload.workflow_run.head_branch}` | ||
}); | ||
const prContextData = pulls.data[0]; | ||
const prNumber = prContextData.number; | ||
const originalSha = prContextData.head.sha; | ||
try { | ||
console.log("Updating PR branch"); | ||
await github.rest.pulls.updateBranch({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
pull_number: prNumber | ||
}); | ||
console.log("PR branch updated"); | ||
let updatedSha = originalSha; | ||
let retries = 0; | ||
const MAX_RETRIES = 10; | ||
while (updatedSha == originalSha && retries++ < MAX_RETRIES) { | ||
console.log(`Waiting for PR branch to update (attempt ${retries}/${MAX_RETRIES})`); | ||
await new Promise(r => setTimeout(r, 500)); | ||
const updatedPR = await github.rest.pulls.get({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
pull_number: prNumber | ||
}); | ||
updatedSha = updatedPR.data.head.sha; | ||
} | ||
} catch (error) { | ||
// The branch is already up to date or can't otherwise be updated | ||
// That's fine, we tried our best | ||
console.warn(error); | ||
} | ||
- name: Checkout Workflow Branch | ||
if: steps.download-artifacts.outputs.found_artifact == 'true' | ||
uses: actions/checkout@v3 | ||
with: | ||
token: ${{secrets.MUTATION_TOKEN}} | ||
token: ${{ secrets.MUTATION_TOKEN }} | ||
ref: ${{ github.event.workflow_run.head_branch }} | ||
repository: ${{ github.event.workflow_run.head_repository.full_name }} | ||
path: repo | ||
|
||
- id: self_mutation | ||
if: steps.download-artifacts.outputs.found_artifact == 'true' | ||
name: Apply downloaded pathes | ||
name: Apply downloaded patches | ||
working-directory: repo | ||
env: | ||
HEAD_REF: ${{ github.event.workflow_run.head_branch }} | ||
run: | | ||
git config user.name "monada-bot[bot]" | ||
git config user.email "[email protected]" | ||
# if ../patches/update.diff/update.diff exists, apply it first | ||
UPDATE_PATCH_FILE="../patches/update.diff/update.diff" | ||
if [ -f $UPDATE_PATCH_FILE ]; then | ||
echo "Updating branch" | ||
git apply --binary $UPDATE_PATCH_FILE | ||
if [ $? -eq 0 ]; then | ||
git add --all | ||
git commit -s -m "Merge branch 'main' into $HEAD_REF" | ||
echo "Patch applied successfully" | ||
rm $UPDATE_PATCH_FILE | ||
else | ||
echo "Patch failed to apply" | ||
cat $UPDATE_PATCH_FILE | ||
exit 1 | ||
fi | ||
fi | ||
for f in $(find ../patches/*.diff/*.diff); do | ||
echo "Applying $f" | ||
git apply --binary $f | ||
if [ $? -eq 0 ]; then | ||
git add --all | ||
git commit -s -m "chore: self mutation ($f)" | ||
git commit -s -m "chore: self mutation ($(basename $f))" | ||
echo "Patch applied successfully" | ||
rm $f | ||
else | ||
|
@@ -116,12 +145,13 @@ jobs: | |
with: | ||
github-token: ${{ secrets.MUTATION_TOKEN }} | ||
script: | | ||
// use API to get the PR number since we can't rely on the context across forks | ||
const pulls = await github.rest.pulls.list({ | ||
per_page: 1, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
head: `${context.payload.workflow_run.head_repository.full_name}:${context.payload.workflow_run.head_branch}` | ||
}); | ||
const prNumber = pulls.data[0].number; | ||
const labels = ["⚠️ pr/review-mutation"]; | ||
|
Oops, something went wrong.