diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index f035a9970814..000000000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,9 +0,0 @@ -version: 2 -updates: - - package-ecosystem: npm - versioning-strategy: "increase" - directory: "/" - schedule: - interval: "weekly" - day: "friday" - open-pull-requests-limit: 20 diff --git a/.github/workflows/build-eslint-jest.yaml b/.github/workflows/build-eslint-jest.yaml deleted file mode 100644 index abca6c6b0b55..000000000000 --- a/.github/workflows/build-eslint-jest.yaml +++ /dev/null @@ -1,47 +0,0 @@ -name: Lint, build and run tests - -on: - push: - branches: [main] - pull_request: - types: [opened, synchronize, reopened] - -jobs: - all: - strategy: - matrix: - os: ['ubuntu-latest', 'windows-latest'] - node-version: ['14'] - fail-fast: true - runs-on: ${{ matrix.os }} - name: ${{ matrix.os }} | Node ${{ matrix.node-version }} latest - steps: - - uses: actions/checkout@v2 - - - name: Setup node - uses: actions/setup-node@v2 - with: - node-version: ${{ matrix.node-version }} - - - name: Cache "node_modules" - uses: actions/cache@v2 - if: matrix.os == 'ubuntu-latest' - with: - path: '**/node_modules' - key: node_modules_${{ runner.os }}_${{ hashFiles('**/yarn.lock') }} - - - name: Install dependencies - run: yarn install --frozen-lockfile - - - name: Build - run: yarn build - - - name: Run ESLint - run: yarn lint - env: - CI: true - - - name: Run tests - run: yarn test - env: - CI: true diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml deleted file mode 100644 index 6bfccfb61b1f..000000000000 --- a/.github/workflows/codeql-analysis.yml +++ /dev/null @@ -1,67 +0,0 @@ -# For most projects, this workflow file will not need changing; you simply need -# to commit it to your repository. -# -# You may wish to alter this file to override the set of languages analyzed, -# or to provide custom queries or build logic. -# -# ******** NOTE ******** -# We have attempted to detect the languages in your repository. Please check -# the `language` matrix defined below to confirm you have the correct set of -# supported CodeQL languages. -# -name: "CodeQL" - -on: - push: - branches: [ main ] - pull_request: - # The branches below must be a subset of the branches above - branches: [ main ] - schedule: - - cron: '42 5 * * 3' - -jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - - strategy: - fail-fast: false - matrix: - language: [ 'javascript' ] - # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] - # Learn more: - # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed - - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v1 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - # queries: ./path/to/local/query, your-org/your-repo/queries@main - - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v1 - - # ℹī¸ Command-line programs to run using the OS shell. - # 📚 https://git.io/JvXDl - - # ✏ī¸ If the Autobuild fails above, remove it and uncomment the following three lines - # and modify them (or add more) to build your code if your project - # uses a compiled language - - #- run: | - # make bootstrap - # make release - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 diff --git a/.github/workflows/create_pr_artifact.yaml b/.github/workflows/create_pr_artifact.yaml deleted file mode 100644 index b5eaf39070bc..000000000000 --- a/.github/workflows/create_pr_artifact.yaml +++ /dev/null @@ -1,47 +0,0 @@ -name: Create PR Artifact - -on: pull_request - -jobs: - create_pr_artifact: - name: Create PR Artifact - if: github.repository == 'redwoodjs/redwood' - runs-on: ubuntu-latest - defaults: - run: - shell: bash - - steps: - - name: Checkout PR - uses: actions/checkout@v2 - - - name: Setup node - uses: actions/setup-node@v2 - with: - node-version: 14 - - - name: Install dependencies - run: yarn install --frozen-lockfile - - - name: Build - run: yarn build - - - name: Create packages - run: | - dirName="bin/${{ github.event.number }}" - mkdir -p $dirName - for d in packages/*/ ; do - (cd "$d" && tgz=$(npm pack) && cp $tgz "../../$dirName/") - done - cd $dirName - sha="${{ github.event.pull_request.head.sha }}" - for f in * ; do - mv -- "$f" "${f%.tgz}-${sha:0:7}.tgz" - done - - - name: Upload artifact - uses: actions/upload-artifact@v2 - with: - name: pr-packages - path: bin/ - retention-days: 1 diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 2c1b195d1a8d..d72e4027c210 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -11,7 +11,7 @@ jobs: if: github.repository == 'redwoodjs/redwood' strategy: matrix: - os: ['ubuntu-latest'] + os: ['windows-latest'] node-version: ['14'] fail-fast: true runs-on: ${{ matrix.os }} @@ -30,17 +30,21 @@ jobs: - name: Create a temporary directory id: createpath + shell: bash run: | project_path=$(mktemp -d -t redwood.XXXXXX) echo "::set-output name=project_path::$project_path" - name: Create a RedwoodJS app + shell: bash run: ./tasks/run-e2e ${{ steps.createpath.outputs.project_path }} --no-start - name: Start server in background - run: yarn rw dev & - working-directory: ${{ steps.createpath.outputs.project_path }} - + shell: bash + run: | + echo "${{ steps.createpath.outputs.project_path }}" + cd "${{ steps.createpath.outputs.project_path }}" + yarn rw dev & - name: Cypress run uses: cypress-io/github-action@v2 diff --git a/.github/workflows/netlify-build.yaml b/.github/workflows/netlify-build.yaml deleted file mode 100644 index b58463fb5e95..000000000000 --- a/.github/workflows/netlify-build.yaml +++ /dev/null @@ -1,21 +0,0 @@ -name: Netlify deploy hook to add new docs on Redwoodjs.com - -on: - push: - branches: - - main - paths: - - '**.md' - release: - types: - - published - -jobs: - deploy_hook: - name: Starting Netlify Deploy - runs-on: ubuntu-latest - steps: - - name: POST build hook - run: | - set -e - curl -X POST https://api.netlify.com/build_hooks/5e72a1a0d832c03eb1f56934 diff --git a/.github/workflows/publish-npm-canary.yaml b/.github/workflows/publish-npm-canary.yaml deleted file mode 100644 index 2bb97eb984f1..000000000000 --- a/.github/workflows/publish-npm-canary.yaml +++ /dev/null @@ -1,47 +0,0 @@ -name: Publish canaray packages to npm - -on: - push: - branches: [main] - tags-ignore: - - v** - -jobs: - build: - if: github.repository == 'redwoodjs/redwood' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 # Required because lerna uses tags to determine the version. - - name: Setup node - uses: actions/setup-node@v2 - with: - node-version: '14' - - name: Print node and yarn versions - run: | - node --version - yarn --version - - name: Install dependencies - run: yarn install --frozen-lockfile --check-files - - - name: Build - run: yarn build - - - name: Run ESLint - run: yarn lint - env: - CI: true - - - name: Run tests - run: yarn test - env: - CI: true - - - name: Publish to npm - run: | - git fetch --depth=1 origin +refs/tags/*:refs/tags/* - echo "//registry.npmjs.org/:_authToken=${NPM_AUTH_TOKEN}" > .npmrc - ./tasks/publish-canary - env: - NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} diff --git a/.github/workflows/publish_pr_packages.yaml b/.github/workflows/publish_pr_packages.yaml deleted file mode 100644 index 9e13c933bd31..000000000000 --- a/.github/workflows/publish_pr_packages.yaml +++ /dev/null @@ -1,82 +0,0 @@ -name: Publish PR packages - -on: - workflow_run: - workflows: ["Create PR Artifact"] - types: - - completed - -jobs: - publish_pr_packages: - name: Publish PR packages - if: github.repository == 'redwoodjs/redwood' - runs-on: ubuntu-latest - defaults: - run: - shell: bash - - steps: - - name: Download artifact - uses: dawidd6/action-download-artifact@v2 - with: - workflow: ${{ github.event.workflow_run.workflow_id }} - workflow_conclusion: success - - - name: Get PR number - id: pr_number - run: | - ls -R - pr_number=$(ls pr-packages) - echo $pr_number - echo "::set-output name=pr_number::$pr_number" - - - name: copy files to s3 - env: - aws_key_id: ${{ secrets.AWS_KEY_ID }} - aws_secret_access_key: ${{ secrets.AWS_SECRET }} - run: | - sudo apt-get update && sudo apt-get -y install awscli - aws configure set aws_access_key_id $aws_key_id - aws configure set aws_secret_access_key $aws_secret_access_key - aws configure set default.region us-east-1 - aws s3 cp --recursive ./pr-packages/ s3://rw-pr-redwoodjs-com/ - - - name: Create comment msg - id: comment_msg - run: | - pr_number=${{ steps.pr_number.outputs.pr_number }} - cd pr-packages/$pr_number - v_sha=$(ls | grep "\.tgz$" | sed 's/\.tgz$//' | head -n1 | awk -F"-" '{ print $(NF-1)"-"$NF }') - msg="### đŸ“Ļ PR Packages%0A" - msg+="%0A" - msg+="
Click to Show Package Download Links%0A" - msg+="%0A" - for p in *; do - msg+="https://rw-pr-redwoodjs-com.s3.amazonaws.com/$pr_number/$p%0A" - done - msg+="
%0A" - msg+="%0A" - msg+="Install this PR by running \`yarn rw upgrade --pr $pr_number:$v_sha\`" - echo "::set-output name=msg::$msg" - - - name: Find Comment - uses: peter-evans/find-comment@v1 - id: fc - with: - issue-number: ${{ steps.pr_number.outputs.pr_number }} - comment-author: 'github-actions[bot]' - - - name: Create comment - if: ${{ steps.fc.outputs.comment-id == 0 }} - uses: peter-evans/create-or-update-comment@v1 - with: - issue-number: ${{ steps.pr_number.outputs.pr_number }} - body: ${{ steps.comment_msg.outputs.msg }} - - - name: Update comment - if: ${{ steps.fc.outputs.comment-id != 0 }} - uses: peter-evans/create-or-update-comment@v1 - with: - comment-id: ${{ steps.fc.outputs.comment-id }} - body: ${{ steps.comment_msg.outputs.msg }} - edit-mode: replace diff --git a/tasks/e2e/cypress/integration/01-tutorial/tutorial.spec.js b/tasks/e2e/cypress/integration/01-tutorial/tutorial.spec.js index 184ba31250cc..e8f93f7cb295 100644 --- a/tasks/e2e/cypress/integration/01-tutorial/tutorial.spec.js +++ b/tasks/e2e/cypress/integration/01-tutorial/tutorial.spec.js @@ -41,14 +41,21 @@ describe('The Redwood Tutorial - Golden path edition', () => { it('1. Our First Page', () => { //redwoodjs.com/tutorial/our-first-page + cy.task('execa', { + cmd: 'yarn redwood generate page home / --force', + cwd: BASE_DIR, + }) cy.visit('http://localhost:8910') - cy.exec(`cd ${BASE_DIR}; yarn redwood generate page home / --force`) cy.get('h1').should('contain', 'HomePage') }) it('2. A Second Page and a Link', () => { // https://redwoodjs.com/tutorial/a-second-page-and-a-link - cy.exec(`cd ${BASE_DIR}; yarn redwood generate page about --force`) + cy.task('execa', { + cmd: 'yarn redwood generate page about --force', + cwd: BASE_DIR, + }) + cy.wait(15000) cy.writeFile( path.join(BASE_DIR, 'web/src/pages/HomePage/HomePage.js'), Step2_1_PagesHome @@ -64,7 +71,11 @@ describe('The Redwood Tutorial - Golden path edition', () => { }) it('3. Layouts', () => { - cy.exec(`cd ${BASE_DIR}; yarn redwood generate layout blog --force`) + cy.task('execa', { + cmd: 'yarn redwood generate layout blog --force', + cwd: BASE_DIR, + }) + cy.wait(5000) cy.writeFile( path.join(BASE_DIR, 'web/src/layouts/BlogLayout/BlogLayout.js'), Step3_1_LayoutsBlog @@ -91,14 +102,31 @@ describe('The Redwood Tutorial - Golden path edition', () => { it('4. Getting Dynamic', () => { // https://redwoodjs.com/tutorial/getting-dynamic cy.writeFile(path.join(BASE_DIR, 'api/db/schema.prisma'), Step4_1_DbSchema) - cy.exec(`rm ${BASE_DIR}/api/db/dev.db`, { failOnNonZeroExit: false }) + cy.task('execa', { + cmd: `yarn rimraf ${BASE_DIR}/api/db/dev.db`, + cwd: BASE_DIR, + }) // need to also handle case where Prisma Client be out of sync - cy.exec( - `cd ${BASE_DIR}; yarn rimraf ./api/db/migrations && yarn rw prisma migrate reset --skip-seed --force` - ) - cy.exec(`cd ${BASE_DIR}; yarn rw prisma migrate dev`) - - cy.exec(`cd ${BASE_DIR}; yarn rw g scaffold post --force`) + cy.task('execa', { + cmd: 'yarn rimraf ./api/db/migrations', + cwd: BASE_DIR, + }) + cy.task('execa', { + cmd: 'yarn rw prisma migrate reset --skip-seed --force', + cwd: BASE_DIR, + }) + cy.wait(5000) + cy.task('execa', { + cmd: 'yarn rw prisma migrate dev', + cwd: BASE_DIR, + }) + cy.wait(5000) + + cy.task('execa', { + cmd: 'yarn rw g scaffold post --force', + cwd: BASE_DIR, + }) + cy.wait(5000) cy.visit('http://localhost:8910/posts') @@ -156,7 +184,11 @@ describe('The Redwood Tutorial - Golden path edition', () => { // https://redwoodjs.com/tutorial/cells cy.visit('http://localhost:8910/') - cy.exec(`cd ${BASE_DIR}; yarn rw g cell BlogPosts --force`) + cy.task('execa', { + cmd: 'yarn rw g cell BlogPosts --force', + cwd: BASE_DIR, + }) + cy.wait(15000) cy.writeFile( path.join(BASE_DIR, 'web/src/components/BlogPostsCell/BlogPostsCell.js'), Step5_1_ComponentsCellBlogPost @@ -181,9 +213,19 @@ describe('The Redwood Tutorial - Golden path edition', () => { it('6. Routing Params', () => { // https://redwoodjs.com/tutorial/routing-params - cy.exec(`cd ${BASE_DIR}; yarn rw g page BlogPost --force`) - cy.exec(`cd ${BASE_DIR}; yarn rw g cell BlogPost --force`) - cy.exec(`cd ${BASE_DIR}; yarn rw g component BlogPost --force`) + cy.task('execa', { + cmd: 'yarn rw g page BlogPost --force', + cwd: BASE_DIR, + }) + cy.task('execa', { + cmd: 'yarn rw g cell BlogPost --force', + cwd: BASE_DIR, + }) + cy.task('execa', { + cmd: 'yarn rw g component BlogPost --force', + cwd: BASE_DIR, + }) + cy.wait(15000) cy.writeFile(path.join(BASE_DIR, 'web/src/Routes.js'), Step6_1_Routes) cy.writeFile( @@ -242,7 +284,11 @@ describe('The Redwood Tutorial - Golden path edition', () => { it("7. Everyone's Favorite Thing to Build: Forms", () => { // https://redwoodjs.com/tutorial/everyone-s-favorite-thing-to-build-forms - cy.exec(`cd ${BASE_DIR}; yarn rw g page contact --force`) + cy.task('execa', { + cmd: 'yarn rw g page contact --force', + cwd: BASE_DIR, + }) + cy.wait(15000) cy.writeFile( path.join(BASE_DIR, 'web/src/layouts/BlogLayout/BlogLayout.js'), Step7_1_BlogLayout @@ -264,12 +310,6 @@ describe('The Redwood Tutorial - Golden path edition', () => { cy.contains('Save').click() cy.get('main').should('contain', 'Please enter a valid email address') - cy.get('input#name').type('test name') - cy.get('input#email').type('foo@bar.com') - cy.get('textarea#message').type('test message') - cy.contains('Save').click() - // console - // {name: "test name", email: "foo@bar.com", message: "test message"} cy.visit('http://localhost:8910/') }) }) diff --git a/tasks/e2e/cypress/integration/02-cli/02-cli-commands.spec.js b/tasks/e2e/cypress/integration/02-cli/02-cli-commands.spec.js deleted file mode 100644 index 88a4fdffa3fb..000000000000 --- a/tasks/e2e/cypress/integration/02-cli/02-cli-commands.spec.js +++ /dev/null @@ -1,61 +0,0 @@ -/* eslint-disable no-undef, camelcase */ -/// - -const BASE_DIR = Cypress.env('RW_PATH') - -describe('Check Redwood cli commands against tutorial', () => { - // These tests aren't visual, as they only run on the CLI - // Disable taking screenshots/videos for this spec - before(() => { - Cypress.config('record', false) - }) - - after(() => { - Cypress.config('record', true) - }) - it('Should run api tests successfully', () => { - cy.exec(`cd ${BASE_DIR}; yarn rw test api --no-watch`, { - timeout: 60000, - }) - .its('code') - .should('eq', 0) - }) - - // @TODO figure out why babel issues happen when linked - it.skip('Should run web tests successfully', () => { - cy.exec(`cd ${BASE_DIR}; yarn rw test web --no-watch`, { - timeout: 60000, - }) - .its('code') - .should('eq', 0) - }) - - it('Should run build successfully (no prerender)', () => { - // Check if webpack build on web, and babel build on api - // work correctly - cy.exec(`cd ${BASE_DIR}; yarn rw build --no-prerender`, { - timeout: 60000, - }) - .its('code') - .should('eq', 0) - }) - - it('Should prerender about and homepage', () => { - // Check if prerender is working - cy.exec(`cd ${BASE_DIR}; yarn rw prerender`, { - timeout: 60000, - }) - .its('code') - .should('eq', 0) - - const WEB_DIST = `${BASE_DIR}/web/dist` - - // Check prerendered files are generated - // Prerender prop added to routes in codemods/Step6_1_Routes.js - cy.readFile(`${WEB_DIST}/index.html`).should('contain', 'Redwood Blog') - cy.readFile(`${WEB_DIST}/about.html`).should( - 'contain', - 'This site was created to demonstrate my mastery of Redwood' - ) - }) -}) diff --git a/tasks/e2e/cypress/plugins/index.js b/tasks/e2e/cypress/plugins/index.js index aa9918d21530..cf2aee1333f4 100644 --- a/tasks/e2e/cypress/plugins/index.js +++ b/tasks/e2e/cypress/plugins/index.js @@ -11,6 +11,7 @@ // This function is called when a project is opened or re-opened (e.g. due to // the project's config changing) +const execa = require('execa') /** * @type {Cypress.PluginConfig} @@ -18,4 +19,15 @@ module.exports = (on, config) => { // `on` is used to hook into various events Cypress emits // `config` is the resolved Cypress config + on('task', { + execa: async (args) => { + await execa(args.cmd, [], { + shell: true, + cleanup: true, + cwd: args.cwd, + }) + + return 0 + }, + }) }