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
158 changes: 158 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
name: Test Action

on:
push:
branches: [master, main, 'feat/**']
pull_request:
branches: [master, main]

jobs:
# ── npm ──────────────────────────────────────────────────────────────────
test-npm:
name: Test — npm (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4

- name: Run action with npm (default)
id: setup
uses: ./
with:
version: 'latest'
node-version: '22'
package-manager: 'npm'

- name: Verify CLI version output is set
shell: bash
run: |
echo "CLI version: ${{ steps.setup.outputs.cli-version }}"
if [ "${{ steps.setup.outputs.cli-version }}" = "unknown" ]; then
echo "ERROR: cli-version output was 'unknown'"
exit 1
fi

- name: Verify ng is on PATH
shell: bash
run: ng version

# ── pnpm ─────────────────────────────────────────────────────────────────
test-pnpm:
name: Test — pnpm (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4

- name: Run action with pnpm
id: setup
uses: ./
with:
version: 'latest'
node-version: '22'
package-manager: 'pnpm'

- name: Verify CLI version output is set
shell: bash
run: |
echo "CLI version: ${{ steps.setup.outputs.cli-version }}"
if [ "${{ steps.setup.outputs.cli-version }}" = "unknown" ]; then
echo "ERROR: cli-version output was 'unknown'"
exit 1
fi

- name: Verify ng is on PATH
shell: bash
run: ng version

# ── yarn ─────────────────────────────────────────────────────────────────
test-yarn:
name: Test — yarn (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4

- name: Run action with yarn
id: setup
uses: ./
with:
version: 'latest'
node-version: '22'
package-manager: 'yarn'

- name: Verify CLI version output is set
shell: bash
run: |
echo "CLI version: ${{ steps.setup.outputs.cli-version }}"
if [ "${{ steps.setup.outputs.cli-version }}" = "unknown" ]; then
echo "ERROR: cli-version output was 'unknown'"
exit 1
fi

- name: Verify ng is on PATH
shell: bash
run: ng version

# ── pinned version ────────────────────────────────────────────────────────
test-pinned-version:
name: Test — pinned Angular CLI version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Run action with pinned Angular CLI version
id: setup
uses: ./
with:
version: '17.3.8'
node-version: '20'
package-manager: 'npm'

- name: Verify the correct version was installed
shell: bash
run: |
INSTALLED="${{ steps.setup.outputs.cli-version }}"
echo "Installed: $INSTALLED"
if [ "$INSTALLED" != "17.3.8" ]; then
echo "ERROR: expected 17.3.8, got $INSTALLED"
exit 1
fi

# ── Node version matrix ───────────────────────────────────────────────────
test-node-versions:
name: Test — Node ${{ matrix.node }}
runs-on: ubuntu-latest
strategy:
matrix:
node: ['18', '20', '22']
steps:
- uses: actions/checkout@v4

- name: Run action with Node ${{ matrix.node }}
id: setup
uses: ./
with:
version: 'latest'
node-version: ${{ matrix.node }}
package-manager: 'npm'

- name: Verify node version
shell: bash
run: |
NODE_VER=$(node --version)
echo "Node version: $NODE_VER"
if [[ "$NODE_VER" != v${{ matrix.node }}* ]]; then
echo "ERROR: expected Node ${{ matrix.node }}, got $NODE_VER"
exit 1
fi

- name: Verify ng is on PATH
shell: bash
run: ng version
50 changes: 50 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Changelog

All notable changes to this project will be documented in this file.

## [2.0.0] — 2026-05-21

### Added
- `node-version` input — choose Node.js 18, 20, 22, or any version (default: `22`)
- `package-manager` input — supports `npm`, `yarn`, and `pnpm` (default: `npm`)
- `cache-dependency-path` input — monorepo support, point to any lock file
- Integration test workflow covering npm, pnpm, yarn, and pinned CLI version
- Windows and macOS runner coverage in CI

### Changed
- Converted from Node.js action to composite action — no compilation step, no `dist/` directory
- Upgraded Node.js runtime from 20 → 22
- Action name updated to `Angular Setup` for better marketplace discoverability
- Completely rewritten README with copy-paste examples for all package managers

### Removed
- TypeScript source (`src/action.ts`)
- Compiled dist (`dist/action.js`)
- `package.json`, `package-lock.json`, `tsconfig.json` — no longer needed

### Migration from v1
All existing `v1` workflows continue to work unchanged — new inputs are optional with backwards-compatible defaults.

```yml
# v1 (still works)
- uses: mayurrawte/github-angular-actions@v1
with:
version: '17.3.8'

# v2 (recommended)
- uses: mayurrawte/github-angular-actions@v2
with:
version: '17.3.8'
node-version: '22'
package-manager: 'npm'
```

## [1.1.0] — 2022-10-01

### Changed
- Migrated codebase to TypeScript

## [1.0.0] — 2021

### Added
- Initial release: install Angular CLI at a specific version with npm cache
149 changes: 134 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,150 @@

# Github Angular Actions
# Angular Setup — GitHub Action

[![MIT License](https://img.shields.io/badge/License-MIT-green.svg)](https://choosealicense.com/licenses/mit/)
![Test Action](https://github.com/mayurrawte/github-angular-actions/actions/workflows/test.yml/badge.svg)
[![GitHub Marketplace](https://img.shields.io/badge/Marketplace-Angular%20Setup-blue?logo=github)](https://github.com/marketplace/actions/angular-github-actions)
![Platforms](https://img.shields.io/badge/runs%20on-ubuntu%20%7C%20windows%20%7C%20macos-lightgrey)

> **One step.** Set up Node.js, cache your package manager, and install Angular CLI.
> Works with **npm**, **yarn**, and **pnpm** — no boilerplate required.

---

## Quick start

```yml
- uses: mayurrawte/github-angular-actions@v2
```

Installs the latest Angular CLI on Node 22 with npm caching. Zero config.

---

## Inputs

GitHub Action to install Angular CLI with optional version selection.
The action now caches the npm cache to speed up subsequent runs.
| Input | Default | Description |
|-------|---------|-------------|
| `version` | `latest` | Angular CLI version — e.g. `17.3.8`, `18.0.0`, or `latest` |
| `node-version` | `22` | Node.js version — e.g. `22`, `20`, `18` |
| `package-manager` | `npm` | `npm`, `yarn`, or `pnpm` |
| `cache-dependency-path` | _(repo root)_ | Lock file path for monorepos |

## Outputs

| Output | Description |
|--------|-------------|
| `cli-version` | Installed Angular CLI version, e.g. `17.3.8` |

---

## Usage
## Examples

### Default — latest Angular, Node 22, npm

```yml
- name: Install Latest Angular
uses: actions/angular-github-actions
steps:
- uses: actions/checkout@v4
- uses: mayurrawte/github-angular-actions@v2
- run: npm ci
- run: npm run build
```

You can also specify the version
### Pin Angular CLI and Node versions

```yml
- name: Install Angular 12.2.7
uses: actions/angular-github-actions
with:
version: 12.2.7
steps:
- uses: actions/checkout@v4
- uses: mayurrawte/github-angular-actions@v2
with:
version: '17.3.8'
node-version: '20'
- run: npm ci
- run: npm test -- --watch=false --browsers=ChromeHeadless
```
## Outputs

- `cli-version` – the installed Angular CLI version
### Angular 16+ with Jest

Angular 16 and above supports Jest as the test runner. No extra setup needed — just run your test command after the action:

```yml
steps:
- uses: actions/checkout@v4
- uses: mayurrawte/github-angular-actions@v2
with:
version: 'latest'
node-version: '22'
- run: npm ci
- run: npm test # runs Jest if configured via ng generate jest
```

### pnpm

```yml
steps:
- uses: actions/checkout@v4
- uses: mayurrawte/github-angular-actions@v2
with:
node-version: '22'
package-manager: 'pnpm'
- run: pnpm install
- run: pnpm build
```

### yarn

```yml
steps:
- uses: actions/checkout@v4
- uses: mayurrawte/github-angular-actions@v2
with:
node-version: '22'
package-manager: 'yarn'
- run: yarn install --frozen-lockfile
- run: yarn build
```

### Monorepo — lock file in a subdirectory

```yml
steps:
- uses: actions/checkout@v4
- uses: mayurrawte/github-angular-actions@v2
with:
package-manager: 'npm'
cache-dependency-path: 'packages/app/package-lock.json'
- run: npm ci --workspace=packages/app
```

### Use the `cli-version` output downstream

```yml
steps:
- uses: actions/checkout@v4
- uses: mayurrawte/github-angular-actions@v2
id: ng-setup
- run: echo "Running on Angular CLI ${{ steps.ng-setup.outputs.cli-version }}"
```

---

## Why this action?

| Feature | This action | `actions/setup-node` only |
|---------|:-----------:|:-------------------------:|
| Installs Angular CLI globally | ✅ | ❌ |
| Specific CLI version | ✅ | ❌ |
| Node.js version selection | ✅ | ✅ |
| npm caching | ✅ | ✅ |
| **pnpm caching** | ✅ | ✅ (manual config) |
| **yarn caching** | ✅ | ✅ (manual config) |
| Monorepo lock file path | ✅ | ✅ (manual config) |
| Exposes `cli-version` output | ✅ | ❌ |
| Zero config | ✅ | ❌ (need extra step) |

Use this action when `@angular/cli` is **not** in your `devDependencies` — common in legacy projects, shared runner setups, or anywhere you run `ng` directly in CI scripts.

---

## License

Caching for the npm directory is enabled by default to optimize your workflow.
MIT
Loading
Loading