From 925faf0000db515ff41e1feac96f90fc6847acca Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Wed, 16 Aug 2023 10:45:26 +0200 Subject: [PATCH] Combine tests into single workflow --- .github/workflows/ci.yaml | 77 ++++++++++++++++++++++++++++++ .github/workflows/integration.yaml | 2 +- integration/write.mjs | 8 ++-- package.json | 3 +- 4 files changed, 84 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index ed8aaf85..b6e22981 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -67,3 +67,80 @@ jobs: - name: Run tests run: | npm run test:coverage + + integration: + name: Integration testing with Node.js ${{ matrix.node-version }} + runs-on: ubuntu-latest + + strategy: + fail-fast: true + max-parallel: 1 + matrix: + node-version: + - lts/* + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Setup Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: npm + + - name: Install dependencies + run: | + npm ci + + - name: Build + run: | + npm run build --if-present + + - name: Run integration tests + env: + TUMBLR_OAUTH_CONSUMER_KEY: ${{ secrets.TUMBLR_OAUTH_CONSUMER_KEY }} + TUMBLR_OAUTH_CONSUMER_SECRET: ${{ secrets.TUMBLR_OAUTH_CONSUMER_SECRET }} + TUMBLR_OAUTH_TOKEN: ${{ secrets.TUMBLR_OAUTH_TOKEN }} + TUMBLR_OAUTH_TOKEN_SECRET: ${{ secrets.TUMBLR_OAUTH_TOKEN_SECRET }} + run: | + npm run test:integration + + integration-write: + name: Integration testing with Node.js ${{ matrix.node-version }} + runs-on: ubuntu-latest + environment: integration-suite + + strategy: + fail-fast: true + max-parallel: 1 + matrix: + node-version: + - lts/* + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Setup Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: npm + + - name: Install dependencies + run: | + npm ci + + - name: Build + run: | + npm run build --if-present + + - name: Run integration tests + env: + TUMBLR_OAUTH_CONSUMER_KEY: ${{ secrets.TUMBLR_OAUTH_CONSUMER_KEY }} + TUMBLR_OAUTH_CONSUMER_SECRET: ${{ secrets.TUMBLR_OAUTH_CONSUMER_SECRET }} + TUMBLR_OAUTH_TOKEN: ${{ secrets.TUMBLR_OAUTH_TOKEN }} + TUMBLR_OAUTH_TOKEN_SECRET: ${{ secrets.TUMBLR_OAUTH_TOKEN_SECRET }} + run: | + npm run test:integration-write diff --git a/.github/workflows/integration.yaml b/.github/workflows/integration.yaml index 3a69ceb3..c8eec847 100644 --- a/.github/workflows/integration.yaml +++ b/.github/workflows/integration.yaml @@ -8,7 +8,7 @@ on: - master jobs: - tests: + integration-read-only: name: Integration testing with Node.js ${{ matrix.node-version }} runs-on: ubuntu-latest environment: integration-suite diff --git a/integration/write.mjs b/integration/write.mjs index d977b8fd..8d7cd262 100644 --- a/integration/write.mjs +++ b/integration/write.mjs @@ -58,8 +58,8 @@ describe('oauth1 write requests', () => { ); }); - describe('photo post', () => { - it('creates a post via data', async () => { + describe('create photo post', () => { + it('via data', async () => { const data = await readFile(new URL('../test/fixtures/image.jpg', import.meta.url)); const res = await client.createPost(blogName, { @@ -72,7 +72,7 @@ describe('oauth1 write requests', () => { assert.isOk(res); }); - it('creates a slideshow post via data[]', async () => { + it('via data[]', async () => { const data = await readFile(new URL('../test/fixtures/image.jpg', import.meta.url)); const res = await client.createPost(blogName, { @@ -85,7 +85,7 @@ describe('oauth1 write requests', () => { assert.isOk(res); }); - it(`creates a post via data64`, async () => { + it('via data64', async () => { const data = await readFile(new URL('../test/fixtures/image.jpg', import.meta.url), { encoding: 'base64', }); diff --git a/package.json b/package.json index e733c8be..858a19bd 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,8 @@ "gh-pages": "git subtree push --prefix=gh-pages origin gh-pages", "test": "mocha --timeout 100", "test:coverage": "nyc npm run test", - "test:integration": "mocha ./integration", + "test:integration": "mocha ./integration/read-only", + "test:integration-write": "mocha ./integration/write", "lint": "eslint --report-unused-disable-directives --ext 'js' --ext 'mjs' lib test integration" }, "engines": {