Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CI workflow to push dist output to separate branch #146

Merged
merged 1 commit into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions files/.github/workflows/push-dist.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Because this library needs to be built,
# we can't easily point package.json files at the git repo for easy cross-repo testing.
#
# This workflow brings back that capability by placing the compiled assets on a "dist" branch
# (configurable via the "branch" option below)
name: Push dist

on:
push:
branches:
- main
- master

jobs:
push-dist:
name: Push dist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3<% if (pnpm) {%>
- uses: NullVoxPopuli/action-setup-pnpm@v2<%} else {%>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need the different setup for pnpm here? Is it worth the additional complexity here?

- name: Install Node
uses: actions/setup-node@v3
with:
cache: '<%= yarn ? 'yarn' : 'npm' %>'<% } if (yarn || npm) { %>
- name: Install Dependencies
run: <%= yarn ? 'yarn install --frozen-lockfile' : 'npm ci' %><%}%>
- uses: kategengler/[email protected]
with:
branch: dist
token: ${{ secrets.GITHUB_TOKEN }}
working-directory: <%= addonInfo.location %>
30 changes: 30 additions & 0 deletions tests/fixtures/default/.github/workflows/push-dist.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Because this library needs to be built,
# we can't easily point package.json files at the git repo for easy cross-repo testing.
#
# This workflow brings back that capability by placing the compiled assets on a "dist" branch
# (configurable via the "branch" option below)
name: Push dist

on:
push:
branches:
- main
- master

jobs:
push-dist:
name: Push dist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Node
uses: actions/setup-node@v3
with:
cache: 'npm'
- name: Install Dependencies
run: npm ci
- uses: kategengler/[email protected]
with:
branch: dist
token: ${{ secrets.GITHUB_TOKEN }}
working-directory: my-addon
25 changes: 25 additions & 0 deletions tests/fixtures/pnpm/.github/workflows/push-dist.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Because this library needs to be built,
# we can't easily point package.json files at the git repo for easy cross-repo testing.
#
# This workflow brings back that capability by placing the compiled assets on a "dist" branch
# (configurable via the "branch" option below)
name: Push dist

on:
push:
branches:
- main
- master

jobs:
push-dist:
name: Push dist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: NullVoxPopuli/action-setup-pnpm@v2
- uses: kategengler/[email protected]
with:
branch: dist
token: ${{ secrets.GITHUB_TOKEN }}
working-directory: my-addon
30 changes: 30 additions & 0 deletions tests/fixtures/yarn/.github/workflows/push-dist.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Because this library needs to be built,
# we can't easily point package.json files at the git repo for easy cross-repo testing.
#
# This workflow brings back that capability by placing the compiled assets on a "dist" branch
# (configurable via the "branch" option below)
name: Push dist

on:
push:
branches:
- main
- master

jobs:
push-dist:
name: Push dist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Node
uses: actions/setup-node@v3
with:
cache: 'yarn'
- name: Install Dependencies
run: yarn install --frozen-lockfile
- uses: kategengler/[email protected]
with:
branch: dist
token: ${{ secrets.GITHUB_TOKEN }}
working-directory: my-addon
15 changes: 14 additions & 1 deletion tests/smoke-tests/defaults.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
AddonHelper,
assertGeneratedCorrectly,
dirContents,
matchesFixture,
SUPPORTED_PACKAGE_MANAGERS,
} from '../helpers.js';

Expand Down Expand Up @@ -36,20 +37,32 @@ for (let packageManager of SUPPORTED_PACKAGE_MANAGERS) {
expect(await fse.pathExists(yarn), 'yarn.lock does not exist').toBe(false);
expect(await fse.pathExists(pnpm), 'pnpm-lock.yaml does not exist').toBe(false);

await matchesFixture('.github/workflows/push-dist.yml', { cwd: helper.projectRoot });

break;
}
case 'yarn': {
expect(await fse.pathExists(yarn), 'for Yarn: yarn.lock exists').toBe(true);
expect(await fse.pathExists(npm), 'package-lock.json does not exist').toBe(false);
expect(await fse.pathExists(pnpm), 'pnpm-lock.yaml does not exist').toBe(false);

await matchesFixture('.github/workflows/push-dist.yml', {
cwd: helper.projectRoot,
scenario: 'yarn',
});

break;
}
case 'pnpm': {
expect(await fse.pathExists(pnpm), 'for pnpm: pnpm-lock.yaml exists').toBe(true);
expect(await fse.pathExists(npm), 'package-lock.json does not exist').toBe(false);
expect(await fse.pathExists(yarn), 'yarn.lock does not exist').toBe(false);

await matchesFixture('.github/workflows/push-dist.yml', {
cwd: helper.projectRoot,
scenario: 'pnpm',
});

break;
}

Expand All @@ -65,7 +78,7 @@ for (let packageManager of SUPPORTED_PACKAGE_MANAGERS) {
});

it('was generated correctly', async () => {
assertGeneratedCorrectly({ projectRoot: helper.projectRoot });
await assertGeneratedCorrectly({ projectRoot: helper.projectRoot });
});

// Tests are additive, so when running them in order, we want to check linting
Expand Down