From 2a8566ae73643d12acabf412b419552bfa158ba4 Mon Sep 17 00:00:00 2001 From: Helio Machado <0x2b3bfa0+git@googlemail.com> Date: Thu, 24 Oct 2024 02:02:02 +0200 Subject: [PATCH 1/7] Use base URL of GitLab for the `/uploads` URLs --- src/drivers/gitlab.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/drivers/gitlab.js b/src/drivers/gitlab.js index f5cebdbc7..7f4c3441d 100644 --- a/src/drivers/gitlab.js +++ b/src/drivers/gitlab.js @@ -141,7 +141,7 @@ class Gitlab { const { url } = await this.request({ endpoint, method: 'POST', body }); - return { uri: `${repo}${url}`, mime, size }; + return { uri: `${await this.repoBase()}${url}`, mime, size }; } async runnerToken(body) { From 9a7d06f2fb3ba5e152088de7898d8f88db615109 Mon Sep 17 00:00:00 2001 From: Helio Machado <0x2b3bfa0+git@googlemail.com> Date: Thu, 24 Oct 2024 02:04:33 +0200 Subject: [PATCH 2/7] Update gitlab.js --- src/drivers/gitlab.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/drivers/gitlab.js b/src/drivers/gitlab.js index 7f4c3441d..aea364d08 100644 --- a/src/drivers/gitlab.js +++ b/src/drivers/gitlab.js @@ -131,8 +131,6 @@ class Gitlab { } async upload(opts = {}) { - const { repo } = this; - const projectPath = await this.projectPath(); const endpoint = `/projects/${projectPath}/uploads`; const { size, mime, data } = await fetchUploadData(opts); From 57de2dc9e70552fa20f94ef931839030fa8c4ff3 Mon Sep 17 00:00:00 2001 From: Helio Machado <0x2b3bfa0+git@googlemail.com> Date: Thu, 24 Oct 2024 00:50:10 +0000 Subject: [PATCH 3/7] Fix non-native uploads --- cml_qa_tests_dummy | 1 + src/cml.js | 6 ++++-- src/drivers/gitlab.js | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) create mode 160000 cml_qa_tests_dummy diff --git a/cml_qa_tests_dummy b/cml_qa_tests_dummy new file mode 160000 index 000000000..f8b8b49a2 --- /dev/null +++ b/cml_qa_tests_dummy @@ -0,0 +1 @@ +Subproject commit f8b8b49a253243830ef59a7f090eb887157b2b67 diff --git a/src/cml.js b/src/cml.js index b6146d82d..ecabc8edf 100644 --- a/src/cml.js +++ b/src/cml.js @@ -346,12 +346,14 @@ class CML { ({ mime, uri } = await upload(opts)); } - if (!rmWatermark) { + if (!rmWatermark && !native) { const [, type] = mime.split('/'); uri = watermarkUri({ uri, type }); } - uri = preventcacheUri({ uri }); + if (!native) { + uri = preventcacheUri({ uri }); + } if (md && mime.match('(image|video)/.*')) return `![](${uri}${title ? ` "${title}"` : ''})`; diff --git a/src/drivers/gitlab.js b/src/drivers/gitlab.js index aea364d08..202e8708b 100644 --- a/src/drivers/gitlab.js +++ b/src/drivers/gitlab.js @@ -139,7 +139,7 @@ class Gitlab { const { url } = await this.request({ endpoint, method: 'POST', body }); - return { uri: `${await this.repoBase()}${url}`, mime, size }; + return { uri: url, mime, size }; } async runnerToken(body) { From 46d7e02cd18d513be02a15c0aa78c063623835ca Mon Sep 17 00:00:00 2001 From: Helio Machado <0x2b3bfa0+git@googlemail.com> Date: Thu, 24 Oct 2024 00:51:17 +0000 Subject: [PATCH 4/7] fixup! Fix non-native uploads --- cml_qa_tests_dummy | 1 - 1 file changed, 1 deletion(-) delete mode 160000 cml_qa_tests_dummy diff --git a/cml_qa_tests_dummy b/cml_qa_tests_dummy deleted file mode 160000 index f8b8b49a2..000000000 --- a/cml_qa_tests_dummy +++ /dev/null @@ -1 +0,0 @@ -Subproject commit f8b8b49a253243830ef59a7f090eb887157b2b67 From 3612a9be8011cc923d47280208e8012a59cf9970 Mon Sep 17 00:00:00 2001 From: Helio Machado <0x2b3bfa0+git@googlemail.com> Date: Thu, 24 Oct 2024 00:55:55 +0000 Subject: [PATCH 5/7] fixup! Fix non-native uploads --- bin/cml/asset/publish.e2e.test.js | 2 +- src/cml.e2e.test.js | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/bin/cml/asset/publish.e2e.test.js b/bin/cml/asset/publish.e2e.test.js index 21d84de2b..b23038beb 100644 --- a/bin/cml/asset/publish.e2e.test.js +++ b/bin/cml/asset/publish.e2e.test.js @@ -125,7 +125,7 @@ describe('CML e2e', () => { 'assets/test.svg' ); - expect(output.startsWith('https://')).toBe(true); + expect(output.startsWith('/uploads/')).toBe(true); }); test('cml publish /nonexistent produces file error', async () => { diff --git a/src/cml.e2e.test.js b/src/cml.e2e.test.js index 02d19d953..1f7805053 100644 --- a/src/cml.e2e.test.js +++ b/src/cml.e2e.test.js @@ -144,8 +144,8 @@ describe('Gitlab tests', () => { native: true }); - expect(output.startsWith('https://')).toBe(true); - expect(output.includes('cml=png')).toBe(true); + expect(output.startsWith('/uploads/')).toBe(true); + expect(output.includes('cml=png')).toBe(false); }); test('Publish image using gl with markdown', async () => { @@ -159,9 +159,9 @@ describe('Gitlab tests', () => { native: true }); - expect(output.startsWith('![](https://')).toBe(true); + expect(output.startsWith('![](/uploads/')).toBe(true); expect(output.endsWith(` "${title}")`)).toBe(true); - expect(output.includes('cml=png')).toBe(true); + expect(output.includes('cml=png')).toBe(false); }); test('Publish a non image file using gl in markdown', async () => { @@ -175,9 +175,9 @@ describe('Gitlab tests', () => { native: true }); - expect(output.startsWith(`[${title}](https://`)).toBe(true); + expect(output.startsWith(`[${title}](/uploads/`)).toBe(true); expect(output.endsWith(')')).toBe(true); - expect(output.includes('cml=pdf')).toBe(true); + expect(output.includes('cml=pdf')).toBe(false); }); test('Publish a non image file using native', async () => { @@ -191,9 +191,9 @@ describe('Gitlab tests', () => { native: true }); - expect(output.startsWith(`[${title}](https://`)).toBe(true); + expect(output.startsWith(`[${title}](/uploads/`)).toBe(true); expect(output.endsWith(')')).toBe(true); - expect(output.includes('cml=pdf')).toBe(true); + expect(output.includes('cml=pdf')).toBe(false); }); test('Publish should fail with an invalid driver', async () => { From bbf77fa677b0bb9c3c3cca71501433132fad2769 Mon Sep 17 00:00:00 2001 From: Helio Machado <0x2b3bfa0+git@googlemail.com> Date: Thu, 24 Oct 2024 03:04:10 +0200 Subject: [PATCH 6/7] Update gitlab.yml --- .github/workflows/gitlab.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/gitlab.yml b/.github/workflows/gitlab.yml index b7ba07aff..7f1a1fb51 100644 --- a/.github/workflows/gitlab.yml +++ b/.github/workflows/gitlab.yml @@ -59,6 +59,11 @@ jobs: | jq -r .id \ | xargs -0 printf "hash=%s" >> $GITHUB_OUTPUT - run: npm ci + - uses: mxschmitt/action-tmate@v3 + with: + limit-access-to-actor: true + env: + TEST_GITLAB_TOKEN: ${{ github.token }} - name: Run cml-send-comment run: | node bin/cml.js send-comment \ From cee86a47c9b32dfcc8e977990e05393dea9249ba Mon Sep 17 00:00:00 2001 From: Helio Machado <0x2b3bfa0+git@googlemail.com> Date: Thu, 24 Oct 2024 03:40:05 +0200 Subject: [PATCH 7/7] Update gitlab.yml --- .github/workflows/gitlab.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/gitlab.yml b/.github/workflows/gitlab.yml index 7f1a1fb51..b7ba07aff 100644 --- a/.github/workflows/gitlab.yml +++ b/.github/workflows/gitlab.yml @@ -59,11 +59,6 @@ jobs: | jq -r .id \ | xargs -0 printf "hash=%s" >> $GITHUB_OUTPUT - run: npm ci - - uses: mxschmitt/action-tmate@v3 - with: - limit-access-to-actor: true - env: - TEST_GITLAB_TOKEN: ${{ github.token }} - name: Run cml-send-comment run: | node bin/cml.js send-comment \