Skip to content
This repository was archived by the owner on Dec 6, 2022. It is now read-only.

Commit e333786

Browse files
authored
Fix tests (#4)
* Add additional read commands to Makefile * Add .DS_Store to .gitignore * Fix tests
1 parent f34b606 commit e333786

20 files changed

+120
-114
lines changed

.github.template/workflows/check-updates.yml.template

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Check updates
33

44
on:
55
schedule:
6-
- cron: '0 0 1,15 * *'
6+
- cron: '0 0 1 * *'
77

88
env:
99
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
@@ -38,7 +38,7 @@ jobs:
3838
shell: bash
3939
- name: Create PR
4040
if: ${{ steps.git-diff.outputs.count > 0 }}
41-
uses: peter-evans/create-pull-request@v3.6.0
41+
uses: peter-evans/create-pull-request@v3.8.2
4242
env:
4343
HUSKY: 0
4444
with:

.github.template/workflows/security-tests.yml.template renamed to .github.template/workflows/security-tests.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@ jobs:
1818
- uses: actions/checkout@v2.3.4
1919
with:
2020
ref: ${{ github.ref }}
21-
- name: Snyk authenticate
22-
run: ${PM_CLI} run security:auth ${{ secrets.SNYK_API_TOKEN }}
23-
- name: Snyk test
24-
run: ${PM_CLI} run security:test
21+
- uses: snyk/actions/node@master
22+
env:
23+
SNYK_TOKEN: ${{ secrets.SNYK_API_TOKEN }}
2524
codeql_tests:
2625
name: CodeQL
2726
runs-on: ubuntu-latest

.github.template/workflows/unit-tests.yml.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- uses: actions/checkout@v2.3.4
2121
- name: Cache node_modules
2222
id: cache
23-
uses: actions/cache@v2.1.3
23+
uses: actions/cache@v2.1.4
2424
with:
2525
path: '**/node_modules'
2626
key: ${{ runner.os }}-modules-${{ hashFiles('**/${PM_LOCK_FILE}') }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.DS_Store
12
.vscode/*
23
!.vscode/settings.json
34
.env

Makefile

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,18 @@ default:
2323
read -p "📊 CodeClimate test coverage badge (leave empty if you do not have it): " cc_test_coverage_badge; \
2424
if [[ -z "$$cc_test_coverage_badge" ]] ; then cc_test_coverage_badge=''; else cc_test_coverage_badge="$$cc_test_coverage_badge "; fi; \
2525
export CC_TESTS_COVERAGE_BADGE=$$cc_test_coverage_badge; \
26+
read -p "🔧 Name of a CLI that you want to setup using this GitHub Action, e.g. wren: " cli_name; \
27+
[ -z "$$cli_name" ] && echo '❌ CLI name cannot be empty.' && exit 1; \
28+
export CLI_NAME=$$cli_name; \
29+
read -p "🗄 File extension that this GitHub Action will download to install, e.g. zip (zip): " cli_extension; \
30+
[ -z "$$cli_extension" ] && cli_extension='zip'; \
31+
export CLI_EXTENSION=$$cli_extension; \
32+
read -p "🌐 First part of URL that will be used to download CLI tool, e.g. if url to download CLI tool looks like https://github.com/wren-lang/wren-cli/releases/download/0.3.0/wren_cli-linux-0.3.0.zip then you should enter https://github.com/wren-lang/wren-cli/releases/download: " cli_url; \
33+
[ -z "$$cli_url" ] && echo '❌ CLI URL cannot be empty.' && exit 1; \
34+
export CLI_URL=$$cli_url; \
35+
read -p "🔢 Latest available version of $$cli_name tool: " latest_version; \
36+
[ -z "$$latest_version" ] && echo '❌ Version cannot be empty.' && exit 1; \
37+
export LATEST_VERSION=$$latest_version; \
2638
envsubst < README.md.template > README.md; \
2739
rm -f README.md.template; \
2840
envsubst < action.yml.template > action.yml; \
@@ -42,14 +54,14 @@ default:
4254
rm -f .github.template/ISSUE_TEMPLATE/feature_request.md.template; \
4355
envsubst < .github.template/workflows/check-updates.yml.template > .github.template/workflows/check-updates.yml; \
4456
rm -f .github.template/workflows/check-updates.yml.template; \
45-
envsubst < .github.template/workflows/security-tests.yml.template > .github.template/workflows/security-tests.yml; \
46-
rm -f .github.template/workflows/security-tests.yml.template; \
4757
envsubst < .github.template/workflows/unit-tests.yml.template > .github.template/workflows/unit-tests.yml; \
4858
rm -f .github.template/workflows/unit-tests.yml.template; \
4959
envsubst < .husky.template/pre-commit.template > .husky.template/pre-commit; \
5060
rm -f .husky.template/pre-commit.template; \
5161
envsubst < .husky.template/pre-push.template > .husky.template/pre-push; \
52-
rm -f .husky.template/pre-push.template
62+
rm -f .husky.template/pre-push.template; \
63+
envsubst < src/consts.ts.template > src/consts.ts; \
64+
rm -f src/consts.ts.template
5365
@rm -rf .github
5466
@mv .github.template .github
5567
@mv .husky.template .husky

action.yml.template

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ description: '${REPO_TITLE} GitHub Action'
55
branding:
66
icon: terminal
77
color: gray-dark
8+
inputs:
9+
version:
10+
description: '${CLI_NAME} version.'
11+
required: false
12+
default: ${LATEST_VERSION}
813
runs:
914
using: 'node12'
1015
main: 'dist/index.js'

package.json.template

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,24 +33,24 @@
3333
"winston": "3.3.3"
3434
},
3535
"devDependencies": {
36-
"@types/chai": "4.2.14",
36+
"@types/chai": "4.2.15",
3737
"@types/jest": "26.0.20",
38-
"@types/node": "14.14.21",
39-
"@typescript-eslint/eslint-plugin": "4.13.0",
40-
"@typescript-eslint/parser": "4.13.0",
38+
"@types/node": "14.14.31",
39+
"@typescript-eslint/eslint-plugin": "4.15.2",
40+
"@typescript-eslint/parser": "4.15.2",
4141
"@vercel/ncc": "0.27.0",
42-
"chai": "4.2.0",
43-
"eslint": "7.18.0",
42+
"chai": "4.3.0",
43+
"eslint": "7.20.0",
4444
"eslint-config-google": "0.14.0",
4545
"git-branch-is": "4.0.0",
46-
"husky": "5.0.6",
46+
"husky": "5.1.1",
4747
"jest": "26.6.3",
4848
"jest-circus": "26.6.3",
4949
"markdownlint-cli": "0.26.0",
5050
"mocha-param": "2.0.1",
51-
"snyk": "1.437.4",
52-
"ts-jest": "26.4.4",
53-
"typescript": "4.1.3"
51+
"snyk": "1.461.0",
52+
"ts-jest": "26.5.2",
53+
"typescript": "4.2.2"
5454
},
5555
"snyk": true
5656
}

src/Cache.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { addPath } from '@actions/core'
22
import { cacheDir } from '@actions/tool-cache'
3-
import fs from 'fs'
3+
import { chmodSync } from 'fs'
44
import path from 'path'
55
import { Logger } from 'winston'
66
import CliExeNameProvider from './CliExeNameProvider'
@@ -13,14 +13,14 @@ export default class Cache implements ICache {
1313

1414
constructor(
1515
version: string,
16-
provider: ICliExeNameProvider = new CliExeNameProvider()) {
16+
provider: ICliExeNameProvider = new CliExeNameProvider(version)) {
1717
this.version = version
1818
this.provider = provider
1919
this.log = LoggerFactory.create('Cache')
2020
}
2121

2222
async cache(execFilePath: string): Promise<void> {
23-
fs.chmodSync(execFilePath, '777')
23+
chmodSync(execFilePath, '777')
2424
this.log.info(
2525
`Access permissions of ${execFilePath} file was changed to 777.`)
2626
const folderPath: string = path.dirname(execFilePath)

src/Downloader.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { downloadTool } from '@actions/tool-cache'
22
import fs from 'fs'
33
import { Logger } from 'winston'
4-
import { CLI_NAME } from './consts'
4+
import { CLI_EXTENSION, CLI_NAME } from './consts'
55
import LoggerFactory from './LoggerFactory'
66

77
export default class Downloader implements IDownloader {
@@ -11,7 +11,7 @@ export default class Downloader implements IDownloader {
1111
this.log.info(`Downloading ${CLI_NAME} from ${url}`)
1212
const zipPathOld: string = await downloadTool(url)
1313
this.log.info(`Downloaded to ${zipPathOld}`)
14-
const zipPathNew: string = zipPathOld + '.zip'
14+
const zipPathNew: string = zipPathOld + '.' + CLI_EXTENSION
1515
fs.renameSync(zipPathOld, zipPathNew)
1616
this.log.info(`Renamed to ${zipPathNew}`)
1717
return zipPathNew

src/UrlProvider.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import CliFileNameBuilder from './CliFileNameBuilder'
2+
import { CLI_EXTENSION, CLI_URL } from './consts'
23

34
export default class UrlProvider implements IUrlProvider {
45
private builder: ICliFileNameBuilder
@@ -12,6 +13,6 @@ export default class UrlProvider implements IUrlProvider {
1213
}
1314

1415
getUrl(): string {
15-
return '{PROJECT_URL}' + `${this.version}/${this.builder.build()}.zip`
16+
return `${CLI_URL}/${this.version}/${this.builder.build()}.${CLI_EXTENSION}`
1617
}
1718
}

0 commit comments

Comments
 (0)