Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
aduh95 committed Jan 23, 2024
2 parents 7681b7a + b7e8a08 commit 2a9cd56
Show file tree
Hide file tree
Showing 84 changed files with 2,482 additions and 1,819 deletions.
218 changes: 192 additions & 26 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,205 @@ on:
paths:
- .github/workflows/e2e.yml

concurrency: ${{ github.workflow }}--${{ github.ref }}
concurrency:
group:
${{ github.workflow }}--${{ github.event.pull_request.head.repo.full_name ||
github.repository }} -- ${{ github.head_ref || github.ref }}
cancel-in-progress:
# For PRs coming from forks, we need the previous job to run until the end
# to be sure it can remove the `safe to test` label before it affects the next run.
${{ github.event.pull_request.head.repo.full_name == github.repository }}

permissions:
pull-requests: write
env:
YARN_ENABLE_GLOBAL_CACHE: false

jobs:
compare_diff:
runs-on: ubuntu-latest
env:
DIFF_BUILDER: true
outputs:
diff: ${{ steps.diff.outputs.OUTPUT_DIFF }}
is_accurate_diff: ${{ steps.diff.outputs.IS_ACCURATE_DIFF }}
steps:
- name: Checkout sources
uses: actions/checkout@v3
with:
fetch-depth: 2
ref:
${{ github.event.pull_request && format('refs/pull/{0}/merge',
github.event.pull_request.number) || github.sha }}
- name: Check if there are "unsafe" changes
id: build_chain_changes
# If there are changes in JS script that generates the output, we cannot
# test them here without human review to make sure they don't contain
# someting "nasty".
run: |
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "MIGHT_CONTAIN_OTHER_CHANGES<<$EOF" >> "$GITHUB_OUTPUT"
git --no-pager diff HEAD^ --name-only bin package.json yarn.lock babel.config.js >> "$GITHUB_OUTPUT"
echo "$EOF" >> "$GITHUB_OUTPUT"
- run: git reset HEAD^ --hard
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run:
echo "dir=$(corepack yarn config get cacheFolder)" >> $GITHUB_OUTPUT

- uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: lts/*
- name: Install dependencies
run:
corepack yarn workspaces focus $(corepack yarn workspaces list --json
| jq -r .name | awk '/^@uppy-example/{ next } { if ($0!="uppy.io")
print $0 }')
env:
# https://docs.cypress.io/guides/references/advanced-installation#Skipping-installation
CYPRESS_INSTALL_BINARY: 0
- run: corepack yarn build:lib
- name: Store output file
run: tar cf /tmp/previousVersion.tar packages/@uppy/*/lib
- name: Fetch source from the PR
if: steps.build_chain_changes.outputs.MIGHT_CONTAIN_OTHER_CHANGES == ''
run: |
git checkout FETCH_HEAD -- packages
echo 'IS_ACCURATE_DIFF=true' >> "$GITHUB_ENV"
- name: Fetch source from the PR
if:
steps.build_chain_changes.outputs.MIGHT_CONTAIN_OTHER_CHANGES != '' &&
(!github.event.pull_request || (github.event.action == 'labeled' &&
github.event.label.name == 'safe to test' &&
github.event.pull_request.state == 'open') ||
(github.event.pull_request.head.repo.full_name == github.repository &&
github.event.event_name != 'labeled'))
run: |
git reset FETCH_HEAD --hard
corepack yarn workspaces focus $(\
corepack yarn workspaces list --json | \
jq -r .name | \
awk '/^@uppy-example/{ next } { if ($0!="uppy.io") print $0 }'\
)
echo 'IS_ACCURATE_DIFF=true' >> "$GITHUB_ENV"
env:
# https://docs.cypress.io/guides/references/advanced-installation#Skipping-installation
CYPRESS_INSTALL_BINARY: 0
- name: Fetch source from the PR
if:
steps.build_chain_changes.outputs.MIGHT_CONTAIN_OTHER_CHANGES != '' &&
github.event.pull_request.head.repo.full_name != github.repository &&
(github.event.action != 'labeled' || github.event.label.name != 'safe
to test')
run: |
git checkout FETCH_HEAD -- packages
- run: corepack yarn build:lib
- name: Store output file
run: tar cf /tmp/newVersion.tar packages/@uppy/*/lib
- name: Setup git
run: |
git config --global user.email "actions@github.com"
git config --global user.name "GitHub Actions"
git init /tmp/uppy
echo '*.map' > /tmp/uppy/.gitignore
- name: Install dformat
run: |
curl -fsSL https://dprint.dev/install.sh | sh
cd /tmp/uppy && echo '{"plugins":[]}' > dprint.json && "$HOME/.dprint/bin/dprint" config add typescript
- name: Extract previous version
run: cd /tmp/uppy && tar xf /tmp/previousVersion.tar
- name: Format previous output code
run: cd /tmp/uppy && "$HOME/.dprint/bin/dprint" fmt **/*.js
- name: Commit previous version
run: cd /tmp/uppy && git add -A . && git commit -m 'previous version'
- name: Extract new version
run: cd /tmp/uppy && tar xf /tmp/newVersion.tar
- name: Format new output code
run: cd /tmp/uppy && "$HOME/.dprint/bin/dprint" fmt **/*.js
- name: Build diff
id: diff
run: |
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "OUTPUT_DIFF<<$EOF" >> "$GITHUB_OUTPUT"
cd /tmp/uppy && git --no-pager diff >> "$GITHUB_OUTPUT"
echo "$EOF" >> "$GITHUB_OUTPUT"
echo "IS_ACCURATE_DIFF=$IS_ACCURATE_DIFF" >> "$GITHUB_OUTPUT"
- name: Add/update comment
if: github.event.pull_request
uses: marocchino/sticky-pull-request-comment@v2
with:
message: |
<details><summary>Diff output files</summary>
```diff
${{ steps.diff.outputs.OUTPUT_DIFF || 'No diff' }}
```
${{ env.IS_ACCURATE_DIFF != 'true' && format(fromJson('"The following build files have been modified and might affect the actual diff:\n\n```\n{0}\n```"'), steps.build_chain_changes.outputs.MIGHT_CONTAIN_OTHER_CHANGES) || '' }}
</details>
- name: Remove 'safe to test' label if cancelled
if:
cancelled() && github.event.pull_request &&
github.event.pull_request.head.repo.full_name != github.repository
run: gh pr edit "$NUMBER" --remove-label 'safe to test'
env:
NUMBER: ${{ github.event.pull_request.number }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
toggle-pending-e2e-label:
# Add the 'pending end-to-end tests' label for PRs that come from forks.
# For those PRs, we want to review the code before running e2e tests.
# See https://securitylab.github.com/research/github-actions-preventing-pwn-requests/.
needs: [compare_diff]
if:
github.event.pull_request.state == 'open' &&
github.event.pull_request.head.repo.full_name != github.repository &&
github.event.action != 'labeled'
runs-on: ubuntu-latest
steps:
- name: Add label
if:
(needs.compare_diff.outputs.diff != '' ||
!needs.compare_diff.outputs.is_accurate_diff) &&
(!contains(github.event.pull_request.labels.*.name, 'safe to test') &&
!contains(github.event.pull_request.labels.*.name, 'pending end-to-end
tests'))
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run:
gh pr edit "$PR_URL" --repo ${{ github.repository }} --add-label
'pending end-to-end tests'
- name: Remove label
if:
needs.compare_diff.outputs.diff == '' &&
needs.compare_diff.outputs.is_accurate_diff &&
(contains(github.event.pull_request.labels.*.name, 'safe to test') ||
contains(github.event.pull_request.labels.*.name, 'pending end-to-end
tests'))
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run:
gh pr edit "$PR_URL" --remove-label 'safe to test' --remove-label
'pending end-to-end tests'

e2e:
needs: [compare_diff]
if:
${{ !github.event.pull_request ||
(contains(github.event.pull_request.labels.*.name, 'safe to test') &&
github.event.pull_request.state == 'open') ||
${{ needs.compare_diff.outputs.diff != '' && (!github.event.pull_request
|| (github.event.action == 'labeled' && github.event.label.name == 'safe
to test' && github.event.pull_request.state == 'open') ||
(github.event.pull_request.head.repo.full_name == github.repository &&
github.event.event_name != 'labeled') }}
github.event.event_name != 'labeled')) }}
name: Browser tests
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -109,7 +295,7 @@ jobs:
path: |
e2e/cypress/videos/
e2e/cypress/screenshots/
- name: Remove 'pending end-to-end tests' label
- name: Remove labels
# Remove the 'pending end-to-end tests' label if tests ran successfully
if:
github.event.pull_request &&
Expand All @@ -120,30 +306,10 @@ jobs:
NUMBER: ${{ github.event.pull_request.number }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Remove 'safe to test' label
# Remove the 'safe to test' label to ensure next commit needs approval before re-running this.
if:
always() && github.event.pull_request &&
contains(github.event.pull_request.labels.*.name, 'safe to test')
run: gh pr edit "$NUMBER" --remove-label 'safe to test'
env:
NUMBER: ${{ github.event.pull_request.number }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
add-pending-e2e-label:
# Add the 'pending end-to-end tests' label for PRs that come from forks.
# For those PRs, we want to review the code before running e2e tests.
# See https://securitylab.github.com/research/github-actions-preventing-pwn-requests/.
if:
github.event.pull_request.state == 'open' &&
github.event.pull_request.head.repo.full_name != github.repository &&
!contains(github.event.pull_request.labels.*.name, 'safe to test') &&
!contains(github.event.pull_request.labels.*.name, 'pending end-to-end
tests')
runs-on: ubuntu-latest
steps:
- name: Add label
env:
NUMBER: ${{ github.event.pull_request.number }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run:
gh pr edit "$NUMBER" --repo ${{ github.repository }} --add-label
'pending end-to-end tests'
16 changes: 16 additions & 0 deletions .yarn/patches/@vitest-utils-npm-1.2.1-3028846845.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
diff --git a/dist/error.d.ts b/dist/error.d.ts
index bd657d5311ff3d255dc57a2f7224301d532a3177..8924e0982c64c566f4d9808cde62292d7ed334ac 100644
--- a/dist/error.d.ts
+++ b/dist/error.d.ts
@@ -1,9 +1,9 @@
import { D as DiffOptions } from './types-widbdqe5.js';
import 'pretty-format';

-declare function serializeError(val: any, seen?: WeakMap<WeakKey, any>): any;
+declare function serializeError(val: any, seen?: WeakMap<object, any>): any;
declare function processError(err: any, diffOptions?: DiffOptions): any;
-declare function replaceAsymmetricMatcher(actual: any, expected: any, actualReplaced?: WeakSet<WeakKey>, expectedReplaced?: WeakSet<WeakKey>): {
+declare function replaceAsymmetricMatcher(actual: any, expected: any, actualReplaced?: WeakSet<object>, expectedReplaced?: WeakSet<object>): {
replacedActual: any;
replacedExpected: any;
};
7 changes: 6 additions & 1 deletion bin/build-lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,12 @@ async function buildLib () {
const isTSX = file.endsWith('.tsx')
if (isTSX || file.endsWith('.ts')) { plugins.push(['@babel/plugin-transform-typescript', { disallowAmbiguousJSXLike: true, isTSX, jsxPragma: 'h' }]) }

const { code, map } = await babel.transformFileAsync(file, { sourceMaps: true, plugins })
const { code, map } = await babel.transformFileAsync(file, {
sourceMaps: true,
plugins,
// no comments because https://github.com/transloadit/uppy/pull/4868#issuecomment-1897717779
comments: !process.env.DIFF_BUILDER,
})
const [{ default: chalk }] = await Promise.all([
import('chalk'),
writeFile(libFile, code),
Expand Down
2 changes: 1 addition & 1 deletion examples/aws-companion/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"express": "^4.18.1",
"express-session": "^1.17.3",
"npm-run-all": "^4.1.5",
"vite": "^4.0.0"
"vite": "^5.0.0"
},
"private": true,
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion examples/custom-provider/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"express": "^4.16.2",
"express-session": "^1.15.6",
"npm-run-all": "^4.1.2",
"vite": "^4.0.0"
"vite": "^5.0.0"
},
"private": true,
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion examples/digitalocean-spaces/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"devDependencies": {
"dotenv": "^16.0.1",
"express": "^4.16.2",
"vite": "^4.0.0"
"vite": "^5.0.0"
},
"private": true,
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion examples/multiple-instances/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"@uppy/golden-retriever": "workspace:*"
},
"devDependencies": {
"vite": "^4.0.0"
"vite": "^5.0.0"
},
"private": true,
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion examples/node-xhr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"devDependencies": {
"npm-run-all": "^4.1.3",
"vite": "^4.0.0"
"vite": "^5.0.0"
},
"private": true,
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion examples/php-xhr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"devDependencies": {
"npm-run-all": "^4.1.3",
"vite": "^4.0.0"
"vite": "^5.0.0"
},
"private": true,
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion examples/python-xhr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"devDependencies": {
"npm-run-all": "^4.1.3",
"vite": "^4.0.0"
"vite": "^5.0.0"
},
"private": true,
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions examples/react-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"preview": "vite preview --port 5050"
},
"devDependencies": {
"@vitejs/plugin-react": "^2.0.0",
"vite": "^4.0.0"
"@vitejs/plugin-react": "^4.0.0",
"vite": "^5.0.0"
}
}
2 changes: 1 addition & 1 deletion examples/redux/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"redux-logger": "^3.0.6"
},
"devDependencies": {
"vite": "^4.0.0"
"vite": "^5.0.0"
},
"private": true,
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion examples/transloadit-markdown-bin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"marked": "^4.0.18"
},
"devDependencies": {
"vite": "^4.0.0"
"vite": "^5.0.0"
},
"private": true,
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion examples/transloadit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"type": "module",
"devDependencies": {
"npm-run-all": "^4.1.5",
"vite": "^4.0.0"
"vite": "^5.0.0"
},
"dependencies": {
"@uppy/core": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion examples/vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"vue": "^2.6.14"
},
"devDependencies": {
"vite": "^4.0.0",
"vite": "^5.0.0",
"vite-plugin-vue2": "^2.0.1",
"vue-template-compiler": "^2.6.14"
}
Expand Down
Loading

0 comments on commit 2a9cd56

Please sign in to comment.