Skip to content

Commit

Permalink
feature(preview): add eas update preview sub-action (#206)
Browse files Browse the repository at this point in the history
* feature(preview): create first draft of preview for EAS Update

* refactor(preview): revise the variables available for the templates

* refactor(preview): finalize the outputs and comment body

* feature(preview): add `more info` links to the PR message

* refactor(preview): update the url to the proper redirect url

* refactor(preview): update the url to the proper redirect url

* refactor(preview): split out the message or summary creation

* test(preview): update message snapshot tests

* test(preview): drop unused test

* docs(preview): add readme to preview subaction

* test(preview): add e2e tests in workflow

* fix(preview): use proper comment output variables
  • Loading branch information
byCedric authored Feb 20, 2023
1 parent b1a8c06 commit f4d6037
Show file tree
Hide file tree
Showing 16 changed files with 26,184 additions and 166 deletions.
101 changes: 101 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,107 @@ jobs:
if: ${{ env.hasAuth == 'true' }}
run: expo whoami

preview:
runs-on: ubuntu-latest
steps:
- name: 🏗 Setup repo
uses: actions/checkout@v3

- name: 🏗 Setup Node
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: yarn

- name: 🏗 Setup EAS
uses: ./
with:
eas-version: latest
token: ${{ secrets.EXPO_TOKEN }}

- name: 🏗 Setup project
run: yarn create expo-app ./temp

- name: 👷 Configure project
working-directory: ./temp
run: |
eas init --id ${{ secrets.EXPO_PROJECT_ID }} --force --non-interactive
echo $(jq '.expo.runtimeVersion.policy = "sdkVersion"' app.json) > app.json
- name: 🚀 Create preview (without comment)
if: ${{ env.hasAuth == 'true' }}
uses: ./preview
id: no-comment
env:
EXPO_TEST_GITHUB_PULL: 206
with:
working-directory: ./temp
command: eas update --branch test --message "This is a test"
comment: false

- name: 🧪 Comment has content
if: ${{ env.hasAuth == 'true' }}
uses: actions/github-script@v6
with:
script: |
const comment = `${{ steps.no-comment.outputs.comment }}`
if (!comment) {
console.log({ comment });
throw new Error('Message output is empty');
}
- name: 🚀 Create preview (single QR)
if: ${{ env.hasAuth == 'true' }}
id: single-qr
uses: ./preview
env:
EXPO_TEST_GITHUB_PULL: 206
with:
working-directory: ./temp
command: eas update --branch test --message "This is a test"
comment-id: 'projectId:{projectId} single-qr'

- name: 🧪 Single QR has content
if: ${{ env.hasAuth == 'true' }}
uses: actions/github-script@v6
with:
script: |
const comment = `${{ steps.single-qr.outputs.comment }}`
if (!comment) {
console.log({ comment });
throw new Error('Message output is empty');
}
- name: 👷 Configure runtime versions
working-directory: ./temp
run: |
echo $(jq 'del(.expo.runtimeVersion)' app.json) > app.json
echo $(jq '.expo.android.runtimeVersion.policy = "sdkVersion"' app.json) > app.json
echo $(jq '.expo.ios.runtimeVersion.policy = "appVersion"' app.json) > app.json
echo $(jq '.expo.scheme = "expogithubaction"' app.json) > app.json
- name: 🚀 Create preview (multi QR)
if: ${{ env.hasAuth == 'true' }}
id: multi-qr
uses: ./preview
env:
EXPO_TEST_GITHUB_PULL: 206
with:
working-directory: ./temp
command: eas update --branch test --message "This is a test"
comment-id: 'projectId:{projectId} multi-qr'

- name: 🧪 Multi QR has content
if: ${{ env.hasAuth == 'true' }}
uses: actions/github-script@v6
with:
script: |
const comment = `${{ steps.multi-qr.outputs.comment }}`
if (!comment) {
console.log({ comment });
throw new Error('Message output is empty');
}
preview-comment:
runs-on: ubuntu-latest
steps:
Expand Down
9 changes: 9 additions & 0 deletions build/command/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20651,6 +20651,15 @@ function pullContext() {
assert(context.eventName === 'pull_request', 'Could not find the pull request context, make sure to run this from a pull_request triggered workflow');
return context.issue;
}
function hasPullContext() {
try {
pullContext();
return true;
}
catch {
return false;
}
}
async function createReaction(options) {
const github = githubApi(options);
if (options.comment_id) {
Expand Down
9 changes: 9 additions & 0 deletions build/preview-comment/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20652,6 +20652,15 @@ function pullContext() {
(0,external_assert_.ok)(github.context.eventName === 'pull_request', 'Could not find the pull request context, make sure to run this from a pull_request triggered workflow');
return github.context.issue;
}
function hasPullContext() {
try {
pullContext();
return true;
}
catch {
return false;
}
}
async function createReaction(options) {
const github = githubApi(options);
if (options.comment_id) {
Expand Down
Loading

0 comments on commit f4d6037

Please sign in to comment.