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

feat: auto start iggy as option #17

Merged
merged 14 commits into from
Nov 27, 2024
6 changes: 3 additions & 3 deletions .github/workflows/action-self-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Setup iggy (using local GitHub Action)
uses: "./"
with:
version: "0.4.71"
version: "0.4.82"
Tchoupinax marked this conversation as resolved.
Show resolved Hide resolved

- name: Print $PATH for iggy
run: which iggy-server
Expand All @@ -40,8 +40,8 @@ jobs:
- name: Check version is the one asked
run: |
VERSION=$(iggy-server --version | grep -oP 'server \K[0-9]+\.[0-9]+\.[0-9]+')
if [ "$VERSION" != "0.4.71" ]; then
echo "Error: Expected version 0.4.71, but got $VERSION"
if [ "$VERSION" != "0.4.82" ]; then
echo "Error: Expected version 0.4.82, but got $VERSION"
exit 1
fi
echo "Version is correct: $VERSION"
1 change: 1 addition & 0 deletions .github/workflows/check-dist.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Check Transpiled JavaScript
on:
pull_request:
types: [ready_for_review]
branches:
- main
paths:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Checks
on:
pull_request:
types: [ready_for_review]
paths:
- "src/**/.ts"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/merge-checks.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Merge checks
on:
pull_request:
types: [opened, reopened, synchronize, labeled, unlabeled]
types: [ready_for_review, reopened, synchronize, labeled, unlabeled]

jobs:
check-labels:
Expand Down
41 changes: 35 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,45 @@ jobs:
name: Test setup-iggy
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup iggy
uses: iggy-rs/setup-iggy@v1
with:
version: "0.4.72"
- name: Print iggy version
run: iggy-server --version
```

## Options

<!-- action-docs-header source="action.yml" -->

<!-- action-docs-header source="action.yml" -->

<!-- action-docs-description source="action.yml" -->
## Description

A GitHub Action to run iggy server
<!-- action-docs-description source="action.yml" --> # applicable for actions only

<!-- action-docs-inputs source="action.yml" -->
## Inputs

| name | description | required | default |
| --- | --- | --- | --- |
| `version` | <p>The Iggy version to launch.</p> | `false` | `default` |
| `autostart` | <p>Set to false if you do not want to start iggy server automatically</p> | `false` | `true` |
<!-- action-docs-inputs source="action.yml" -->

<!-- action-docs-outputs source="action.yml" -->
## Outputs

| name | description |
| --- | --- |
| `version` | <p>The Iggy version that was launched.</p> |
<!-- action-docs-outputs source="action.yml" -->

<!-- action-docs-runs source="action.yml" -->
## Runs

This action is a `node20` action.
<!-- action-docs-runs source="action.yml" --> # applicable for actions only

## Contributions

Any pull request is welcome!
Expand Down
6 changes: 5 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ inputs:
version:
description: "The Iggy version to launch."
required: false
default: "0.4.72"
default: "default"
autostart:
description: "Set to false if you do not want to start iggy server automatically"
required: false
default: "true"
outputs:
version:
description: "The Iggy version that was launched."
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"main": "dist/index.js",
"scripts": {
"build": "tsc && ncc build --no-cache --no-source-map-register",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix"
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"docs": "action-docs --update-readme"
},
"dependencies": {
"@actions/core": "1.11.1",
Expand All @@ -25,6 +26,7 @@
"devDependencies": {
"@types/node": "22.10.0",
"@vercel/ncc": "0.38.3",
"action-docs": "^2.5.1",
"eslint": "9.15.0",
"eslint-plugin-jsonc": "2.18.2",
"eslint-plugin-prettier": "5.2.1",
Expand Down
8 changes: 7 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as core from "@actions/core";

import { setupBinary } from "./binary";
import { startIggyServer } from "./start-server";

const DEFAULT_VERSION = "latest";

Expand All @@ -9,11 +10,16 @@ async function main() {
if (version == null || version == "") {
version = DEFAULT_VERSION;
}
const autoStart = core.getBooleanInput("autostart", { required: false });

try {
core.info(`Installing iggy:${version} and adding it to GitHub Actions Path`);

await setupBinary(version);

if (autoStart) {
core.info("Starting server...");
startIggyServer();
}
} catch (error) {
if (error instanceof Error) {
core.setFailed(error.message);
Expand Down
10 changes: 10 additions & 0 deletions src/start-server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import * as core from "@actions/core";

import { spawn } from "child_process";

export function startIggyServer() {
const iggy = spawn("iggy-server", [], { detached: true, stdio: "ignore" });
iggy.unref();

core.info("Server started!");
}
Loading
Loading