-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from issue-ops/versioning
Versioning and config
- Loading branch information
Showing
16 changed files
with
173 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
name: CodeQL Configuration | ||
|
||
paths-ignore: | ||
- node_modules | ||
- dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: Continuous Delivery | ||
|
||
on: | ||
pull_request: | ||
types: | ||
- closed | ||
branches: | ||
- main | ||
|
||
# This is required to be able to update tags and create releases | ||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
release: | ||
name: Release Version | ||
runs-on: ubuntu-latest | ||
|
||
# Only run this job if the PR was merged | ||
if: ${{ github.event.pull_request.merged == true }} | ||
|
||
steps: | ||
# Checkout the repository with fetch-tags set to true | ||
- name: Checkout | ||
id: checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-tags: true | ||
|
||
# Get the version and update the tags to use in the release | ||
- name: Tag | ||
id: tag | ||
uses: issue-ops/[email protected] | ||
with: | ||
manifest-path: package.json | ||
workspace: ${{ github.workspace }} | ||
ref: main | ||
|
||
# Use the version output from the previous step for the release | ||
# Prepend a 'v' to the beginning (e.g. 'v1.2.3') | ||
- name: Create Release | ||
id: release | ||
uses: issue-ops/[email protected] | ||
with: | ||
tag: v${{ steps.tag.outputs.version }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ name: Continuous Integration | |
|
||
on: | ||
push: | ||
branches: | ||
branches-ignore: | ||
- main | ||
pull_request: | ||
branches: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ name: Super Linter | |
|
||
on: | ||
push: | ||
branches: | ||
branches-ignore: | ||
- main | ||
pull_request: | ||
branches: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,16 @@ | ||
/** | ||
* Unit tests for the action's index.ts file. | ||
* Unit tests for the action's entrypoint, src/index.ts | ||
*/ | ||
|
||
import * as core from '@actions/core' | ||
import fs from 'fs' | ||
import * as main from '../src/main' | ||
|
||
const getInputMock = jest.spyOn(core, 'getInput') | ||
const setOutputMock = jest.spyOn(core, 'setOutput') | ||
// Mock the action's entrypoint | ||
const runMock = jest.spyOn(main, 'run').mockImplementation() | ||
|
||
describe('index', () => { | ||
beforeEach(() => { | ||
jest.clearAllMocks() | ||
}) | ||
|
||
it('retrieves the inputs', async () => { | ||
getInputMock.mockImplementation((name: string) => { | ||
switch (name) { | ||
case 'body': | ||
return fs.readFileSync( | ||
'__tests__/fixtures/bug-report/issue.md', | ||
'utf8' | ||
) | ||
case 'csv_to_list': | ||
return 'true' | ||
default: | ||
return '' | ||
} | ||
}) | ||
|
||
const { run } = require('../src/index') | ||
await run() | ||
|
||
expect(getInputMock).toHaveBeenCalledWith('body', { required: true }) | ||
expect(getInputMock).toHaveBeenCalledWith('csv_to_list') | ||
}) | ||
|
||
it('returns the parsed body as JSON', async () => { | ||
getInputMock.mockImplementation((name: string) => { | ||
switch (name) { | ||
case 'body': | ||
return fs.readFileSync( | ||
'__tests__/fixtures/bug-report/issue.md', | ||
'utf8' | ||
) | ||
case 'csv_to_list': | ||
return 'true' | ||
default: | ||
return '' | ||
} | ||
}) | ||
|
||
const expected = JSON.parse( | ||
fs.readFileSync('__tests__/fixtures/bug-report/expected.json', 'utf8') | ||
) | ||
|
||
const { run } = require('../src/index') | ||
await run() | ||
it('calls run when imported', async () => { | ||
require('../src/index') | ||
|
||
expect(setOutputMock).toHaveBeenCalledWith('json', JSON.stringify(expected)) | ||
expect(runMock).toHaveBeenCalled() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/** | ||
* Unit tests for the action's index.ts file. | ||
*/ | ||
|
||
import * as core from '@actions/core' | ||
import * as main from '../src/main' | ||
import fs from 'fs' | ||
|
||
const getInputMock = jest.spyOn(core, 'getInput') | ||
const setOutputMock = jest.spyOn(core, 'setOutput') | ||
|
||
describe('index', () => { | ||
beforeEach(() => { | ||
jest.clearAllMocks() | ||
}) | ||
|
||
it('retrieves the inputs', async () => { | ||
getInputMock.mockImplementation((name: string) => { | ||
switch (name) { | ||
case 'body': | ||
return fs.readFileSync( | ||
'__tests__/fixtures/bug-report/issue.md', | ||
'utf8' | ||
) | ||
case 'csv_to_list': | ||
return 'true' | ||
default: | ||
return '' | ||
} | ||
}) | ||
|
||
await main.run() | ||
|
||
expect(getInputMock).toHaveBeenCalledWith('body', { required: true }) | ||
expect(getInputMock).toHaveBeenCalledWith('csv_to_list') | ||
}) | ||
|
||
it('returns the parsed body as JSON', async () => { | ||
getInputMock.mockImplementation((name: string) => { | ||
switch (name) { | ||
case 'body': | ||
return fs.readFileSync( | ||
'__tests__/fixtures/bug-report/issue.md', | ||
'utf8' | ||
) | ||
case 'csv_to_list': | ||
return 'true' | ||
default: | ||
return '' | ||
} | ||
}) | ||
|
||
const expected = JSON.parse( | ||
fs.readFileSync('__tests__/fixtures/bug-report/expected.json', 'utf8') | ||
) | ||
|
||
await main.run() | ||
|
||
expect(setOutputMock).toHaveBeenCalledWith('json', JSON.stringify(expected)) | ||
}) | ||
}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"name": "parser", | ||
"description": "Convert issue form responses to JSON", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"author": "Nick Alteen <[email protected]>", | ||
"homepage": "https://github.com/issue-ops/parser#readme", | ||
"repository": { | ||
|
@@ -17,7 +17,10 @@ | |
"issueops" | ||
], | ||
"engines": { | ||
"node": ">=18" | ||
"node": ">=20" | ||
}, | ||
"exports": { | ||
".": "./dist/index.js" | ||
}, | ||
"scripts": { | ||
"bundle": "npm run format:write && npm run package", | ||
|
@@ -31,7 +34,6 @@ | |
"all": "npm run format:write && npm run lint && npm run test && npm run package" | ||
}, | ||
"license": "MIT", | ||
"main": "index.js", | ||
"jest": { | ||
"clearMocks": true, | ||
"collectCoverage": true, | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,6 @@ | ||
import * as core from '@actions/core' | ||
import { parse } from './parse' | ||
|
||
/** | ||
* The entrypoint for the action | ||
* The entrypoint for the action. | ||
*/ | ||
export async function run(): Promise<void> { | ||
// Get the input string | ||
const body: string = core.getInput('body', { required: true }) | ||
|
||
// Get other input parameters | ||
const csvToList: boolean = core.getInput('csv_to_list') === 'true' | ||
|
||
core.info('Running action with the following inputs:') | ||
core.info(` csv_to_list: ${csvToList}`) | ||
core.info(` body: ${body}`) | ||
|
||
// Parse the body | ||
const parsedBody = await parse(body, csvToList) | ||
core.debug(`Parsed body: ${JSON.stringify(parsedBody, null, 2)}`) | ||
core.setOutput('json', JSON.stringify(parsedBody)) | ||
} | ||
import { run } from './main' | ||
|
||
run() |
Oops, something went wrong.