feat(ci): cache cli.js's template test (#2670)

This commit is contained in:
Lucas Fernandes Nogueira 2021-09-27 20:50:27 -03:00 committed by GitHub
parent d24fd8d102
commit 7c455b86b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 6 deletions

View File

@ -83,7 +83,7 @@ jobs:
with: with:
path: tooling/cli.rs/target path: tooling/cli.rs/target
# Add date to the cache to keep it up to date # Add date to the cache to keep it up to date
key: ubuntu-latest-nightly-cargo-cli-${{ hashFiles('tooling/cli.rs/Cargo.lock') }}-${{ env.CURRENT_DATE }} key: ${{ matrix.platform }}-stable-cargo-cli-${{ hashFiles('tooling/cli.rs/Cargo.lock') }}-${{ env.CURRENT_DATE }}
# Restore from outdated cache for speed # Restore from outdated cache for speed
restore-keys: | restore-keys: |
${{ matrix.platform }}-stable-cargo-cli-${{ hashFiles('tooling/cli.rs/Cargo.lock') }} ${{ matrix.platform }}-stable-cargo-cli-${{ hashFiles('tooling/cli.rs/Cargo.lock') }}

View File

@ -84,7 +84,7 @@ jobs:
with: with:
path: tooling/bench/tests/target path: tooling/bench/tests/target
# Add date to the cache to keep it up to date # Add date to the cache to keep it up to date
key: ubuntu-latest-nightly-cargo-benches-${{ hashFiles('tooling/bench/tests/Cargo.lock') }}-${{ env.CURRENT_DATE }} key: ${{ matrix.platform }}-nightly-cargo-benches-${{ hashFiles('tooling/bench/tests/Cargo.lock') }}-${{ env.CURRENT_DATE }}
# Restore from outdated cache for speed # Restore from outdated cache for speed
restore-keys: | restore-keys: |
${{ matrix.platform }}-nightly-cargo-benches-${{ hashFiles('tooling/bench/tests/Cargo.lock') }} ${{ matrix.platform }}-nightly-cargo-benches-${{ hashFiles('tooling/bench/tests/Cargo.lock') }}

View File

@ -72,7 +72,7 @@ jobs:
with: with:
path: tooling/bundler/target path: tooling/bundler/target
# Add date to the cache to keep it up to date # Add date to the cache to keep it up to date
key: ubuntu-latest-stable-cargo-bundler-${{ hashFiles('tooling/bundler/Cargo.lock') }}-${{ env.CURRENT_DATE }} key: ${{ matrix.platform }}-stable-cargo-bundler-${{ hashFiles('tooling/bundler/Cargo.lock') }}-${{ env.CURRENT_DATE }}
# Restore from outdated cache for speed # Restore from outdated cache for speed
restore-keys: | restore-keys: |
${{ matrix.platform }}-stable-cargo-bundler-${{ hashFiles('tooling/bundler/Cargo.lock') }} ${{ matrix.platform }}-stable-cargo-bundler-${{ hashFiles('tooling/bundler/Cargo.lock') }}

View File

@ -135,7 +135,7 @@ jobs:
with: with:
path: tooling/cli.rs/target path: tooling/cli.rs/target
# Add date to the cache to keep it up to date # Add date to the cache to keep it up to date
key: ubuntu-latest-nightly-cargo-cli-${{ hashFiles('tooling/cli.rs/Cargo.lock') }}-${{ env.CURRENT_DATE }} key: ${{ matrix.platform }}-stable-cargo-cli-${{ hashFiles('tooling/cli.rs/Cargo.lock') }}-${{ env.CURRENT_DATE }}
# Restore from outdated cache for speed # Restore from outdated cache for speed
restore-keys: | restore-keys: |
${{ matrix.platform }}-stable-cargo-cli-${{ hashFiles('tooling/cli.rs/Cargo.lock') }} ${{ matrix.platform }}-stable-cargo-cli-${{ hashFiles('tooling/cli.rs/Cargo.lock') }}
@ -198,12 +198,23 @@ jobs:
with: with:
path: tooling/cli.rs/target path: tooling/cli.rs/target
# Add date to the cache to keep it up to date # Add date to the cache to keep it up to date
key: ubuntu-latest-nightly-cargo-cli-${{ hashFiles('tooling/cli.rs/Cargo.lock') }}-${{ env.CURRENT_DATE }} key: ${{ matrix.platform }}-stable-cargo-cli-${{ hashFiles('tooling/cli.rs/Cargo.lock') }}-${{ env.CURRENT_DATE }}
# Restore from outdated cache for speed # Restore from outdated cache for speed
restore-keys: | restore-keys: |
${{ matrix.platform }}-stable-cargo-cli-${{ hashFiles('tooling/cli.rs/Cargo.lock') }} ${{ matrix.platform }}-stable-cargo-cli-${{ hashFiles('tooling/cli.rs/Cargo.lock') }}
${{ matrix.platform }}-stable-cargo-cli- ${{ matrix.platform }}-stable-cargo-cli-
- name: Cache template cargo target
uses: actions/cache@v2
with:
path: tooling/cli.js/test/jest/fixtures/empty/src-tauri/target
# Add date to the cache to keep it up to date
key: ${{ matrix.platform }}-stable-template-${{ hashFiles('tooling/cli.rs/templates/app/**') }}-${{ env.CURRENT_DATE }}
# Restore from outdated cache for speed
restore-keys: |
${{ matrix.platform }}-stable-template-${{ hashFiles('tooling/cli.rs/templates/app/**') }}
${{ matrix.platform }}-stable-template-
- name: test - name: test
timeout-minutes: 30 timeout-minutes: 30
run: | run: |

View File

@ -1,6 +1,7 @@
import * as fixtureSetup from '../fixtures/app-test-setup.js' import * as fixtureSetup from '../fixtures/app-test-setup.js'
import { resolve, dirname } from 'path' import { resolve, dirname } from 'path'
import { writeFileSync, readFileSync } from 'fs' import { existsSync, readFileSync, writeFileSync } from 'fs'
import { move } from 'fs-extra'
import { init, build } from 'dist/api/cli' import { init, build } from 'dist/api/cli'
import { fileURLToPath } from 'url' import { fileURLToPath } from 'url'
@ -11,11 +12,18 @@ describe('[CLI] cli.js template', () => {
const cwd = process.cwd() const cwd = process.cwd()
const fixturePath = resolve(currentDirName, '../fixtures/empty') const fixturePath = resolve(currentDirName, '../fixtures/empty')
const tauriFixturePath = resolve(fixturePath, 'src-tauri') const tauriFixturePath = resolve(fixturePath, 'src-tauri')
const outPath = resolve(tauriFixturePath, 'target')
const cacheOutPath = resolve(fixturePath, 'target')
fixtureSetup.initJest('empty') fixtureSetup.initJest('empty')
process.chdir(fixturePath) process.chdir(fixturePath)
const outExists = existsSync(outPath)
if (outExists) {
await move(outPath, cacheOutPath)
}
const { promise } = await init({ const { promise } = await init({
directory: process.cwd(), directory: process.cwd(),
force: true, force: true,
@ -24,6 +32,10 @@ describe('[CLI] cli.js template', () => {
}) })
await promise await promise
if (outExists) {
await move(cacheOutPath, outPath)
}
process.chdir(tauriFixturePath) process.chdir(tauriFixturePath)
const manifestPath = resolve(tauriFixturePath, 'Cargo.toml') const manifestPath = resolve(tauriFixturePath, 'Cargo.toml')