diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 41fc0d3..2ac5e88 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -1,126 +1,56 @@ name: End-to-end tests on: [push] jobs: - vite-latest: + vite-cli-latest: runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Install vue - run: npm create vite@latest test-app -- --template vue - - - name: Add example code - run: | - mv ./example/src/App.vue ./test-app/src/App.vue - sed -i 's/ lang="ts"//' ./test-app/src/App.vue - mv ./example/vite.config.ts ./test-app/vite.config.js - mv ./example/src/assets/test.svg ./test-app/src/assets/test.svg - mv ./example/src/assets/style.svg ./test-app/src/assets/style.svg - mv ./example/src/assets/circle.svg ./test-app/src/assets/circle.svg - mv ./example/public/root.svg ./test-app/public/root.svg - - - name: Build - run: | - cd test-app - npm install - npm install vite-svg-loader --save-dev - npm run build - - - name: Test - uses: cypress-io/github-action@v6 + - uses: actions/checkout@v4 + - run: ./create-test-app.sh "npm create vite@latest test-app -- --template vue" + - uses: cypress-io/github-action@v6 with: start: npm run test:preview - vite-latest-ts: + vite-cli-latest-ts: runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Install vue-ts - run: npm create vite@latest test-app -- --template vue-ts - - - name: Add example code - run: | - mv ./example/src/App.vue ./test-app/src/App.vue - mv ./example/vite.config.ts ./test-app/vite.config.ts - mv ./example/src/vite-env.d.ts ./test-app/src/vite-env.d.ts - mv ./example/src/assets/test.svg ./test-app/src/assets/test.svg - mv ./example/src/assets/style.svg ./test-app/src/assets/style.svg - mv ./example/src/assets/circle.svg ./test-app/src/assets/circle.svg - mv ./example/public/root.svg ./test-app/public/root.svg - - - name: Build - run: | - cd test-app - npm install - npm install vite-svg-loader --save-dev - npm run build - - - name: Test - uses: cypress-io/github-action@v6 + - uses: actions/checkout@v4 + - run: ./create-test-app.sh "npm create vite@latest test-app -- --template vue-ts" --typescript + - uses: cypress-io/github-action@v6 with: start: npm run test:preview - vite-4: + vite-cli-4: runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Install vue - run: npm create vite@4 test-app -- --template vue - - - name: Add example code - run: | - mv ./example/src/App.vue ./test-app/src/App.vue - sed -i 's/ lang="ts"//' ./test-app/src/App.vue - mv ./example/vite.config.ts ./test-app/vite.config.js - mv ./example/src/assets/test.svg ./test-app/src/assets/test.svg - mv ./example/src/assets/style.svg ./test-app/src/assets/style.svg - mv ./example/src/assets/circle.svg ./test-app/src/assets/circle.svg - mv ./example/public/root.svg ./test-app/public/root.svg - - - name: Build - run: | - cd test-app - npm install - npm install vite-svg-loader --save-dev - npm run build - - - name: Test - uses: cypress-io/github-action@v6 + - uses: actions/checkout@v4 + - run: ./create-test-app.sh "npm create vite@4 test-app -- --template vue" + - uses: cypress-io/github-action@v6 with: start: npm run test:preview - vite-4-ts: + vite-cli-4-ts: runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Install vue-ts - run: npm create vite@4 test-app -- --template vue-ts - - - name: Add example code - run: | - mv ./example/src/App.vue ./test-app/src/App.vue - mv ./example/vite.config.ts ./test-app/vite.config.ts - mv ./example/src/vite-env.d.ts ./test-app/src/vite-env.d.ts - mv ./example/src/assets/test.svg ./test-app/src/assets/test.svg - mv ./example/src/assets/style.svg ./test-app/src/assets/style.svg - mv ./example/src/assets/circle.svg ./test-app/src/assets/circle.svg - mv ./example/public/root.svg ./test-app/public/root.svg + - uses: actions/checkout@v4 + - run: ./create-test-app.sh "npm create vite@4 test-app -- --template vue-ts" --typescript + - uses: cypress-io/github-action@v6 + with: + start: npm run test:preview - - name: Build - run: | - cd test-app - npm install - npm install vite-svg-loader --save-dev - npm run build + vue-cli-latest: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - run: ./create-test-app.sh "npm create vue@latest test-app -- --default" + - uses: cypress-io/github-action@v6 + with: + start: npm run test:preview - - name: Test - uses: cypress-io/github-action@v6 + vue-cli-latest-ts: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - run: ./create-test-app.sh "npm create vue@latest test-app -- --default --ts" --typescript + - uses: cypress-io/github-action@v6 with: start: npm run test:preview diff --git a/.npmignore b/.npmignore index 54a22c5..7690590 100644 --- a/.npmignore +++ b/.npmignore @@ -3,3 +3,4 @@ /example /cypress cypress.json +create-test-app.sh diff --git a/create-test-app.sh b/create-test-app.sh new file mode 100755 index 0000000..c77b728 --- /dev/null +++ b/create-test-app.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +$1 # Install vue command, project name should be `test-app` + +# Copy example code and SVGs +cp ./example/src/App.vue ./test-app/src/App.vue +cp ./example/vite.config.ts ./test-app/vite.config.ts +cp ./example/src/vite-env.d.ts ./test-app/src/vite-env.d.ts +cp ./example/src/assets/test.svg ./test-app/src/assets/test.svg +cp ./example/src/assets/style.svg ./test-app/src/assets/style.svg +cp ./example/src/assets/circle.svg ./test-app/src/assets/circle.svg +cp ./example/public/root.svg ./test-app/public/root.svg + +# Commands when not using typescript +if [[ "$2" != "--typescript" ]]; then + mv ./test-app/vite.config.ts ./test-app/vite.config.js # Rename `.ts` to `.js` + sed -i 's/ lang="ts"//' ./test-app/src/App.vue # Remove `lang="ts"` from `