Skip to content

Commit

Permalink
WB-1606: Re-enable snapshots release job (#2072)
Browse files Browse the repository at this point in the history
## Summary:

Now that we have a better path to release the packages in a safer way (#2070 and
#2071), we can re-enable the snapshots release job. re-enable the snapshots
release job to run on every non-draft PR.

Issue: WB-1606

## Test plan:

Verify that the snapshots release job is running on every non-draft PR.

Author: jandrade

Reviewers: jeremywiebe, jeresig

Required Reviewers:

Approved By: jeremywiebe, jeresig

Checks: ✅ codecov/project, ✅ Chromatic - Get results on non-draft regular PRs (ubuntu-latest, 16.x), ✅ Test (ubuntu-latest, 16.x, 2/2), ✅ Test (ubuntu-latest, 16.x, 1/2), ✅ Check build sizes (ubuntu-latest, 16.x), ✅ Lint (ubuntu-latest, 16.x), ✅ Chromatic - Build on non-draft regular PRs / chromatic (ubuntu-latest, 16.x), ⏭  Chromatic - Skip on Release PR (changesets), ✅ Publish npm snapshot (ubuntu-latest, 16.x), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 16.x), ✅ gerald, ✅ Prime node_modules cache for primary configuration (ubuntu-latest, 16.x), ⏭  dependabot

Pull Request URL: #2072
  • Loading branch information
jandrade authored Sep 28, 2023
1 parent 841e769 commit b32ec45
Showing 1 changed file with 76 additions and 77 deletions.
153 changes: 76 additions & 77 deletions .github/workflows/node-ci-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -188,86 +188,85 @@ jobs:
# Always ignore SourceMaps and node_modules:
exclude: "{**/*.map,**/node_modules/**}"

# TODO(WB-1606): re-enable snapshots once release bug is fixed
# publish_snapshot:
# name: Publish npm snapshot
# # We don't publish snapshots on draft PRs or
# # on the main Changeset "Version Packages" PR
# if: |
# github.event.pull_request.draft == false
# && !startsWith(github.head_ref, 'changeset-release/')
# runs-on: ${{ matrix.os }}
# strategy:
# matrix:
# os: [ubuntu-latest]
# node-version: [16.x]
# steps:
# # We need to checkout all history, so that the changeset tool can diff it
# - name: Checkout current commit
# uses: actions/checkout@v3
# with:
# fetch-depth: "0"
# - name: Ensure main branch is avaialble
# run: |
# REF=$(git rev-parse HEAD)
# git checkout main
# git checkout $REF
# - name: Use Node.js ${{ matrix.node-version }} & Install & cache node_modules
# uses: Khan/actions@shared-node-cache-v0
# with:
# node-version: ${{ matrix.node-version }}
publish_snapshot:
name: Publish npm snapshot
# We don't publish snapshots on draft PRs or
# on the main Changeset "Version Packages" PR
if: |
github.event.pull_request.draft == false
&& !startsWith(github.head_ref, 'changeset-release/')
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
node-version: [16.x]
steps:
# We need to checkout all history, so that the changeset tool can diff it
- name: Checkout current commit
uses: actions/checkout@v4
with:
fetch-depth: "0"
- name: Ensure main branch is avaialble
run: |
REF=$(git rev-parse HEAD)
git checkout main
git checkout $REF
- name: Use Node.js ${{ matrix.node-version }} & Install & cache node_modules
uses: Khan/actions@shared-node-cache-v0
with:
node-version: ${{ matrix.node-version }}

# - name: Publish snapshot release to npm
# id: publish-snapshot
# run: ./utils/publish/publish-snapshot.sh # All config is via Github env vars
# env:
# NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish snapshot release to npm
id: publish-snapshot
run: ./utils/publish/publish-snapshot.sh # All config is via Github env vars
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

# - name: Calculate short SHA for this commit
# id: short-sha
# run: echo "short_sha=$(echo ${GITHUB_SHA} | cut -c1-8)" >> $GITHUB_OUTPUT
- name: Calculate short SHA for this commit
id: short-sha
run: echo "short_sha=$(echo ${GITHUB_SHA} | cut -c1-8)" >> $GITHUB_OUTPUT

# # Note: these two actions are locked to the latest version that were
# # published when @jeremy (Jeremy Wiebe) created the original job in Perseus.
# - name: Find existing comment
# uses: peter-evans/find-comment@034abe94d3191f9c89d870519735beae326f2bdb
# id: find-comment
# with:
# issue-number: ${{ github.event.pull_request.number }}
# comment-author: "github-actions[bot]"
# body-includes: "npm Snapshot:"
# Note: these two actions are locked to the latest version that were
# published when @jeremy (Jeremy Wiebe) created the original job in Perseus.
- name: Find existing comment
uses: peter-evans/find-comment@034abe94d3191f9c89d870519735beae326f2bdb
id: find-comment
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: "github-actions[bot]"
body-includes: "npm Snapshot:"

# - name: Create or update npm snapshot comment - Success
# if: steps.publish-snapshot.outputs.npm_snapshot_tag != ''
# uses: peter-evans/create-or-update-comment@67dcc547d311b736a8e6c5c236542148a47adc3d
# with:
# issue-number: ${{ github.event.pull_request.number }}
# comment-id: ${{ steps.find-comment.outputs.comment-id }}
# edit-mode: replace
# body: |
# ## npm Snapshot: Published
# 🎉 Good news!! We've packaged up the latest commit from this PR (${{
# steps.short-sha.outputs.short_sha }}) and published all packages with changesets to npm.
- name: Create or update npm snapshot comment - Success
if: steps.publish-snapshot.outputs.npm_snapshot_tag != ''
uses: peter-evans/create-or-update-comment@67dcc547d311b736a8e6c5c236542148a47adc3d
with:
issue-number: ${{ github.event.pull_request.number }}
comment-id: ${{ steps.find-comment.outputs.comment-id }}
edit-mode: replace
body: |
## npm Snapshot: Published
🎉 Good news!! We've packaged up the latest commit from this PR (${{
steps.short-sha.outputs.short_sha }}) and published all packages with changesets to npm.
# You can install the packages in webapp by running:
# ```sh
# ./services/static/dev/tools/deploy_wonder_blocks.js --tag="${{
# steps.publish-snapshot.outputs.npm_snapshot_tag }}"
# ```
You can install the packages in webapp by running:
```sh
./services/static/dev/tools/deploy_wonder_blocks.js --tag="${{
steps.publish-snapshot.outputs.npm_snapshot_tag }}"
```
# Packages can also be installed manually by running:
# ```sh
# yarn add @khanacademy/wonder-blocks-<package-name>@${{
# steps.publish-snapshot.outputs.npm_snapshot_tag }}
# ```
# - name: Create or update npm snapshot comment - Failure
# if: steps.publish-snapshot.outputs.npm_snapshot_tag == ''
# uses: peter-evans/create-or-update-comment@67dcc547d311b736a8e6c5c236542148a47adc3d
# with:
# issue-number: ${{ github.event.pull_request.number }}
# comment-id: ${{ steps.find-comment.outputs.comment-id }}
# edit-mode: replace
# body: |
# ## npm Snapshot: **NOT** Published
# 🤕 Oh noes!! We couldn't find any changesets in this PR (${{
# steps.short-sha.outputs.short_sha }}). As a result, we did **not** publish an npm snapshot for you.
Packages can also be installed manually by running:
```sh
yarn add @khanacademy/wonder-blocks-<package-name>@${{
steps.publish-snapshot.outputs.npm_snapshot_tag }}
```
- name: Create or update npm snapshot comment - Failure
if: steps.publish-snapshot.outputs.npm_snapshot_tag == ''
uses: peter-evans/create-or-update-comment@67dcc547d311b736a8e6c5c236542148a47adc3d
with:
issue-number: ${{ github.event.pull_request.number }}
comment-id: ${{ steps.find-comment.outputs.comment-id }}
edit-mode: replace
body: |
## npm Snapshot: **NOT** Published
🤕 Oh noes!! We couldn't find any changesets in this PR (${{
steps.short-sha.outputs.short_sha }}). As a result, we did **not** publish an npm snapshot for you.

0 comments on commit b32ec45

Please sign in to comment.