diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 01ee50c2..bed0ba67 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -80,6 +80,5 @@ jobs: continue-on-error: true env: NPM_TOKEN: ${{ secrets.CANARY_NPM_TOKEN }} - E2E: 1 REGISTRY: 'https://npm.tei.su' - run: cd e2e && node publish-canary.js + run: cd e2e && ./cli.sh ci-publish diff --git a/e2e/cli.sh b/e2e/cli.sh index a92e8466..34785ca8 100755 --- a/e2e/cli.sh +++ b/e2e/cli.sh @@ -34,7 +34,11 @@ case "$method" in chmod -R 777 .verdaccio docker compose up -d verdaccio docker compose run --rm --build build - docker compose run --rm --build test + docker compose run --build test + ;; + "ci-publish") + export CURRENT_COMMIT=$(git rev-parse HEAD) + docker compose run --rm -e REGISTRY -e NPM_TOKEN -e CURRENT_COMMIT test publish-canary ;; *) echo "Unknown command" diff --git a/e2e/publish-canary.js b/e2e/publish-canary.js index e4de2a7a..7cdc8ba4 100644 --- a/e2e/publish-canary.js +++ b/e2e/publish-canary.js @@ -6,11 +6,8 @@ const fs = require('fs') const path = require('path') const { execSync } = require('child_process') -const { REGISTRY } = require('../scripts/publish.js') -const { getCurrentCommit } = require('../scripts/git-utils.js') - // setup token -const { NPM_TOKEN } = process.env +const { NPM_TOKEN, REGISTRY, CURRENT_COMMIT } = process.env if (!NPM_TOKEN) { console.error('NPM_TOKEN is not set!') @@ -22,7 +19,7 @@ execSync(`npm config set //${REGISTRY.replace(/^https?:\/\//, '')}/:_authToken $ const nodeModulesDir = path.join(__dirname, 'node_modules') const mtcuteDir = path.join(nodeModulesDir, '@mtcute') -const commit = getCurrentCommit().slice(0, 7) +const commit = CURRENT_COMMIT.slice(0, 7) for (const pkg of fs.readdirSync(mtcuteDir)) { const pkgJsonPath = path.join(mtcuteDir, pkg, 'package.json') diff --git a/e2e/runner.js b/e2e/runner.js index 8a40eba3..810e96e6 100644 --- a/e2e/runner.js +++ b/e2e/runner.js @@ -80,6 +80,7 @@ async function main() { if (!process.argv[2]) { console.log('Usage: node runner.js ') console.log(' where is one of:') + console.log(' publish-canary - publish everything to canary npm') console.log(' all - run all tests') console.log(' - (one of %s) - run tests for that directory', DIRS.join(', ')) console.log(' - run tests for that file') @@ -88,6 +89,12 @@ async function main() { const [dir, file] = process.argv.slice(2) + if (dir === 'publish-canary') { + cp.execSync('node publish-canary.js', { stdio: 'inherit' }) + + return + } + if (dir === 'all') { for (const d of DIRS) { console.log('Entering %s', d) diff --git a/scripts/git-utils.js b/scripts/git-utils.js index 3b902ee4..a82b8115 100644 --- a/scripts/git-utils.js +++ b/scripts/git-utils.js @@ -1,9 +1,5 @@ const cp = require('child_process') -function getCurrentCommit() { - return cp.execSync('git rev-parse HEAD', { encoding: 'utf8', stdio: 'pipe' }).trim() -} - function getLatestTag() { try { const res = cp.execSync('git describe --abbrev=0 --tags', { encoding: 'utf8', stdio: 'pipe' }).trim() @@ -68,5 +64,4 @@ module.exports = { findChangedFilesSince, getCommitsSince, parseConventionalCommit, - getCurrentCommit, }