Skip to content

Commit

Permalink
Merge pull request #25 from issue-ops/ncalteen
Browse files Browse the repository at this point in the history
Cleanup
  • Loading branch information
ncalteen authored Nov 1, 2023
2 parents 211a810 + 2d32a4d commit 8d3ecb8
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 31 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/** -diff linguist-generated=true
9 changes: 4 additions & 5 deletions .github/workflows/check-dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@ on:
paths-ignore:
- '**.md'

permissions:
contents: read

jobs:
check-dist:
name: Check dist/
runs-on: ubuntu-latest

permissions:
contents: read
statuses: write

steps:
- name: Checkout
id: checkout
Expand All @@ -30,7 +29,7 @@ jobs:
id: setup-node
uses: actions/setup-node@v4
with:
node-version: 20
node-version-file: .node-version
cache: npm

- name: Install Dependencies
Expand Down
10 changes: 3 additions & 7 deletions .github/workflows/continuous-delivery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ on:
branches:
- main

# This is required to be able to update tags and create releases
permissions:
contents: write

Expand All @@ -16,18 +15,17 @@ jobs:
name: Release Version
runs-on: ubuntu-latest

# Only run this job if the PR was merged
if: ${{ github.event.pull_request.merged == true }}
if: |
github.event.pull_request.merged == true &&
startsWith(github.head_ref, 'dependabot/') == false
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]
Expand All @@ -36,8 +34,6 @@ jobs:
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]
Expand Down
13 changes: 6 additions & 7 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,16 @@ on:
branches:
- main

permissions:
actions: read
checks: write
contents: read

jobs:
continuous-integration:
name: Continuous Integration
runs-on: ubuntu-latest

permissions:
actions: read
checks: write
contents: read
statuses: write

steps:
- name: Checkout
id: checkout
Expand All @@ -28,7 +27,7 @@ jobs:
id: setup-node
uses: actions/setup-node@v4
with:
node-version: 20
node-version-file: .node-version
cache: npm

- name: Install Dependencies
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/super-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ jobs:

- name: Setup Node.js
id: setup-node
uses: actions/setup-node@v4
uses: actions/setup-node@v3
with:
node-version: 20
node-version-file: .node-version
cache: npm

- name: Install Dependencies
Expand Down
1 change: 1 addition & 0 deletions .node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20.6.0
8 changes: 7 additions & 1 deletion __tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@
import * as main from '../src/main'

// Mock the action's entrypoint
const runMock = jest.spyOn(main, 'run').mockImplementation()
let runMock: jest.SpyInstance

describe('index', () => {
beforeEach(() => {
jest.clearAllMocks()

runMock = jest.spyOn(main, 'run').mockImplementation()
})

it('calls run when imported', async () => {
require('../src/index')

Expand Down
14 changes: 10 additions & 4 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import * as core from '@actions/core'
import * as main from '../src/main'

// Mock the GitHub Actions core library
const getInputMock = jest.spyOn(core, 'getInput').mockImplementation()
const setFailedMock = jest.spyOn(core, 'setFailed').mockImplementation()
const setOutputMock = jest.spyOn(core, 'setOutput').mockImplementation()
let getInputMock: jest.SpyInstance
let setFailedMock: jest.SpyInstance
let setOutputMock: jest.SpyInstance

// Mock the action's main function
const runMock = jest.spyOn(main, 'run')
let runMock: jest.SpyInstance

// Mock Octokit
jest.mock('@octokit/rest', () => ({
Expand All @@ -21,6 +21,12 @@ jest.mock('@octokit/rest', () => ({
describe('action', () => {
beforeEach(() => {
jest.clearAllMocks()

getInputMock = jest.spyOn(core, 'getInput').mockImplementation()
setFailedMock = jest.spyOn(core, 'setFailed').mockImplementation()
setOutputMock = jest.spyOn(core, 'setOutput').mockImplementation()

runMock = jest.spyOn(main, 'run')
})

it('reads valid inputs', async () => {
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "releaser",
"description": "Handle releases for GitHub repositories",
"version": "0.1.2",
"version": "0.1.3",
"author": "Nick Alteen <[email protected]>",
"homepage": "https://github.com/issue-ops/releaser#readme",
"repository": {
Expand All @@ -25,13 +25,14 @@
"scripts": {
"bundle": "npm run format:write && npm run package",
"ci-test": "jest",
"coverage": "make-coverage-badge --output-path ./badges/coverage.svg",
"format:write": "prettier --write '**/*.ts'",
"format:check": "prettier --check '**/*.ts'",
"lint": "npx eslint . -c ./.github/linters/.eslintrc.yml",
"package": "ncc build src/index.ts -o dist --source-map --license licenses.txt",
"package:watch": "npm run package -- --watch",
"test": "(jest && make-coverage-badge --output-path ./badges/coverage.svg) || make-coverage-badge --output-path ./badges/coverage.svg",
"all": "npm run format:write && npm run lint && npm run test && npm run package"
"test": "jest",
"all": "npm run format:write && npm run lint && npm run test && npm run coverage && npm run package"
},
"license": "MIT",
"jest": {
Expand Down

0 comments on commit 8d3ecb8

Please sign in to comment.