Skip to content
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
49 changes: 37 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,42 @@
name: CI Workflow
name: CI

on:
push:
branches:
- main
pull_request: {}
branches: [main]
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
test:
name: Test
quality:
name: Quality checks
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- name: Hello World
run: echo "Hello from my construct!"
- name: Show Environment
run: 'echo "Environment: production"'
- name: Checkout
uses: actions/checkout@v4

- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: 1.2.22

- name: Install dependencies
run: bun install --frozen-lockfile

- name: Build
run: bun run build

- name: Typecheck
run: bun run typecheck

- name: Lint
run: bun run lint

- name: Contract tests (workflow generator)
run: bun run test -- packages/core/src/workflow-generator.test.ts
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
"type": "module",
"private": true,
"scripts": {
"build": "bun run --filter './packages/*' build",
"build": "bun run --filter @dotgithub/core build && bun run --filter @dotgithub/cli build",
"typecheck": "bun run build",
"lint": "echo 'lint rules pending (tracked in backlog)'",
"format:check": "bunx prettier --check .",
"test": "vitest run",
"test:watch": "vitest",
"test:ui": "vitest --ui",
Expand Down Expand Up @@ -32,7 +35,7 @@
"peerDependencies": {
"typescript": "^5"
},
"packageManager": "bun@1.1.40",
"packageManager": "bun@1.2.22",
"dependencies": {
"@changesets/cli": "^2.29.5",
"axios": "^1.7.0",
Expand Down
28 changes: 28 additions & 0 deletions packages/core/src/__snapshots__/workflow-generator.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`workflow-generator > generateWorkflowYaml > should keep workflow/job/step key ordering stable 1`] = `
"# This file is autogenerated by DotGitHub. Do not edit manually.
name: Ordered Workflow
on:
push:
branches:
- main
permissions:
actions: read
contents: read
env:
CI: "true"
concurrency:
group: \${{ github.workflow }}-\${{ github.ref }}
cancel-in-progress: true
jobs:
test:
name: Test Job
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- name: Run tests
run: bun test
"
`;
35 changes: 35 additions & 0 deletions packages/core/src/workflow-generator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,41 @@ describe('workflow-generator', () => {
expect(yaml).toContain('continue-on-error: true');
expect(yaml).toContain('working-directory: ./src');
});

it('should keep workflow/job/step key ordering stable', () => {
const workflow: GitHubWorkflow = {
name: 'Ordered Workflow',
on: {
push: { branches: ['main'] },
},
permissions: {
contents: 'read',
actions: 'read',
},
env: {
CI: 'true',
},
concurrency: {
group: '${{ github.workflow }}-${{ github.ref }}',
'cancel-in-progress': true,
},
jobs: {
test: {
name: 'Test Job',
permissions: { contents: 'read' },
'runs-on': 'ubuntu-latest',
steps: [
{
name: 'Run tests',
run: 'bun test',
},
],
},
},
};

expect(generateWorkflowYaml(workflow)).toMatchSnapshot();
});
});

describe('createWorkflow', () => {
Expand Down