Skip to content

Commit 746ea31

Browse files
authored
Merge branch 'master' into d003-issue-comments
2 parents d2711ac + e9546a2 commit 746ea31

File tree

10 files changed

+54
-51
lines changed

10 files changed

+54
-51
lines changed

.github/workflows/codeql-analysis.yml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: CodeQL
2+
3+
on:
4+
pull_request:
5+
paths-ignore:
6+
- '**.md'
7+
- assets/**
8+
schedule:
9+
- cron: '0 0 * * *' # everyday @ 0000 UTC
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref_name }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
analyze:
17+
name: Analyze
18+
runs-on: ubuntu-latest
19+
permissions:
20+
actions: read
21+
contents: read
22+
security-events: write
23+
steps:
24+
- uses: actions/checkout@v3
25+
- uses: github/codeql-action/init@v2
26+
with:
27+
languages: javascript
28+
- uses: github/codeql-action/autobuild@v2
29+
- uses: github/codeql-action/analyze@v2

.github/workflows/test-deploy.yml

+8-27
Original file line numberDiff line numberDiff line change
@@ -107,44 +107,25 @@ jobs:
107107
- run: npm ${{ inputs.release && 'publish' || 'publish --dry-run' }}
108108
env:
109109
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
110-
- name: install ldid
111-
run: |
110+
- run: |
112111
sudo apt install --yes libplist-dev
113112
git clone --branch v2.1.5 git://git.saurik.com/ldid.git
114113
sudo g++ -pipe -o /usr/bin/ldid ldid/ldid.cpp -I. -x c ldid/{lookup2.c,sha1.h} -lplist -lcrypto
115-
- id: build
116-
name: build
117-
run: |
118-
echo ::set-output name=tag::${GITHUB_REF#refs/tags/}
114+
- run: |
119115
cp node_modules/@npcz/magic/dist/magic.mgc assets/magic.mgc
120116
npx --yes pkg --no-bytecode --public-packages "*" --public package.json
121-
rm assets/magic.mgc
122-
for cmd in '' runner publish pr; do
123-
build/cml-linux-x64 $cmd --version
124-
done
117+
for cmd in '' runner publish pr; do build/cml-linux-x64 $cmd --version; done
125118
cp build/cml-linux{-x64,}
126119
cp build/cml-macos{-x64,}
127-
- uses: softprops/action-gh-release@v1
128-
if: inputs.release
129-
with:
130-
files: |
131-
build/cml-alpine-arm64
132-
build/cml-alpine-x64
133-
build/cml-linux-arm64
134-
build/cml-linuxstatic-arm64
135-
build/cml-linuxstatic-x64
136-
build/cml-linux-x64
137-
build/cml-linux
138-
build/cml-macos-arm64
139-
build/cml-macos-x64
140-
build/cml-macos
141-
build/cml-win-arm64.exe
142-
build/cml-win-x64.exe
120+
- if: inputs.release
121+
run:
122+
find build -type f | xargs gh release upload $(basename ${{
123+
github.head_ref }})
143124
env:
144125
GITHUB_TOKEN: ${{ secrets.TEST_GITHUB_TOKEN }}
145126
images:
146127
needs: packages
147128
secrets: inherit
148129
uses: ./.github/workflows/images.yml
149130
with:
150-
release: ${{ inputs.release }}
131+
release: ${{ inputs.release || false }}

bin/cml/asset/publish.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ exports.handler = async (opts) => {
1515
opts.native = true;
1616
}
1717

18-
const { file, repo, native, asset: path } = opts;
19-
const cml = new CML({ ...opts, repo: native ? repo : 'cml' });
18+
const { file, asset: path } = opts;
19+
const cml = new CML({ ...opts });
2020
const output = await cml.publish({ ...opts, path });
2121

2222
if (!file) console.log(output);

bin/cml/comment/create.js

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ exports.options = kebabcaseKeys({
3030
},
3131
publish: {
3232
type: 'boolean',
33+
default: true,
3334
description: 'Upload any local images found in the Markdown report'
3435
},
3536
publishUrl: {

bin/cml/comment/create.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe('Comment integration tests', () => {
2424
--commit-sha, --head-sha Commit SHA linked to this comment
2525
[string] [default: \\"HEAD\\"]
2626
--publish Upload any local images found in the Markdown report
27-
[boolean]
27+
[boolean] [default: true]
2828
--publish-url Self-hosted image server URL
2929
[string] [default: \\"https://asset.cml.dev\\"]
3030
--watch Watch for changes and automatically update the

bin/cml/runner/launch.js

+4-12
Original file line numberDiff line numberDiff line change
@@ -338,16 +338,8 @@ const run = async (opts) => {
338338
process.on(signal, () => shutdown({ ...opts, reason: signal }));
339339
});
340340

341-
const {
342-
driver,
343-
workdir,
344-
cloud,
345-
labels,
346-
name,
347-
reuse,
348-
reuseIdle,
349-
dockerVolumes
350-
} = opts;
341+
const { workdir, cloud, labels, name, reuse, reuseIdle, dockerVolumes } =
342+
opts;
351343

352344
await cml.repoTokenCheck();
353345

@@ -375,7 +367,7 @@ const run = async (opts) => {
375367
}
376368

377369
if (reuseIdle) {
378-
if (driver === 'bitbucket') {
370+
if (cml.driver === 'bitbucket') {
379371
throw new Error(
380372
'cml runner flag --reuse-idle is unsupported by bitbucket'
381373
);
@@ -396,7 +388,7 @@ const run = async (opts) => {
396388
if (dockerVolumes.length && cml.driver !== 'gitlab')
397389
winston.warn('Parameters --docker-volumes is only supported in gitlab');
398390

399-
if (driver === 'github')
391+
if (cml.driver === 'github')
400392
winston.warn(
401393
'Github Actions timeout has been updated from 72h to 35 days. Update your workflow accordingly to be able to restart it automatically.'
402394
);

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@dvcorg/cml",
3-
"version": "0.18.1",
3+
"version": "18.0.4",
44
"description": "<p align=\"center\"> <img src=\"https://static.iterative.ai/img/cml/title_strip_trim.png\" width=400> </p>",
55
"author": {
66
"name": "Iterative Inc",

src/cml.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,10 @@ const inferToken = () => {
6969
const inferDriver = (opts = {}) => {
7070
const { repo } = opts;
7171
if (repo) {
72-
if (repo.includes('github.com')) return GITHUB;
73-
if (repo.includes('gitlab.com')) return GITLAB;
74-
if (/bitbucket\.(com|org)/.test(repo)) return BB;
72+
const url = new URL(repo);
73+
if (url.hostname === 'github.com') return GITHUB;
74+
if (url.hostname === 'gitlab.com') return GITLAB;
75+
if (/bitbucket\.(com|org)/.test(url.hostname)) return BB;
7576
}
7677

7778
if (GITHUB_REPOSITORY) return GITHUB;

src/drivers/github.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,10 @@ const octokit = (token, repo) => {
6666
onAbuseLimit: throttleHandler
6767
}
6868
};
69-
70-
if (!repo.includes('github.com')) {
69+
const { host, hostname } = new url.URL(repo);
70+
if (hostname !== 'github.com') {
7171
// GitHub Enterprise, use the: repo URL host + '/api/v3' - as baseURL
7272
// as per: https://developer.github.com/enterprise/v3/enterprise-admin/#endpoint-urls
73-
const { host } = new url.URL(repo);
7473
octokitOptions.baseUrl = `https://${host}/api/v3`;
7574
}
7675

0 commit comments

Comments
 (0)