Skip to content

Commit 76064f4

Browse files
authored
ci: switch to GHA (#342)
* ci: switch to GHA * test: don't run symlink tests on Windows
1 parent 645b7db commit 76064f4

File tree

8 files changed

+136
-86
lines changed

8 files changed

+136
-86
lines changed

.circleci/config.yml

-50
This file was deleted.

.github/workflows/release.yml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
test:
10+
uses: ./.github/workflows/test.yml
11+
12+
release:
13+
name: Release
14+
runs-on: ubuntu-latest
15+
needs: test
16+
environment: npm
17+
permissions:
18+
id-token: write # for CFA and npm provenance
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
22+
with:
23+
persist-credentials: false
24+
- name: Setup Node.js
25+
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
26+
with:
27+
node-version: 20.x
28+
cache: 'yarn'
29+
- name: Install
30+
run: yarn install --frozen-lockfile
31+
- uses: continuousauth/action@732eeb237ac0a0b330a7247f744ddc57898ff9c4 # v1.0.4
32+
with:
33+
project-id: ${{ secrets.CFA_PROJECT_ID }}
34+
secret: ${{ secrets.CFA_SECRET }}
35+
npm-token: ${{ secrets.NPM_TOKEN }}

.github/workflows/test.yml

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Test
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
schedule:
8+
- cron: '0 22 * * 3'
9+
workflow_call:
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
test:
16+
name: Test
17+
strategy:
18+
matrix:
19+
node-version:
20+
- '20.10'
21+
- '18.18'
22+
- '16.20'
23+
- '14.16'
24+
os:
25+
- macos-latest
26+
- ubuntu-22.04
27+
- windows-latest
28+
runs-on: "${{ matrix.os }}"
29+
steps:
30+
- name: Install Rosetta
31+
if: ${{ matrix.os == 'macos-latest' && matrix.node-version == '14.16' }}
32+
run: /usr/sbin/softwareupdate --install-rosetta --agree-to-license
33+
- name: Install Linux Dependencies
34+
if: ${{ matrix.os == 'ubuntu-22.04' }}
35+
run: sudo apt-get update && sudo apt-get install --no-install-recommends -y libasound2 libgtk-3-0 libnss3 libxss1 libxtst6 xvfb libgbm-dev
36+
- name: Checkout
37+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
38+
- name: Setup Node.js
39+
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
40+
with:
41+
node-version: "${{ matrix.node-version }}"
42+
cache: 'yarn'
43+
architecture: ${{ matrix.os == 'macos-latest' && matrix.node-version == '14.16' && 'x64' || env.RUNNER_ARCH }}
44+
- name: Install (Node.js v16+)
45+
if : ${{ matrix.node-version != '14.16' }}
46+
run: yarn install --frozen-lockfile
47+
- name: Install (Node.js < v16)
48+
if : ${{ matrix.node-version == '14.16' }}
49+
run: yarn install --frozen-lockfile --ignore-engines
50+
- name: Test
51+
run: yarn test

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# @electron/asar - Electron Archive
22

3-
[![CircleCI build status](https://circleci.com/gh/electron/asar/tree/main.svg?style=shield)](https://circleci.com/gh/electron/asar/tree/main)
3+
[![Test](https://github.com/electron/asar/actions/workflows/test.yml/badge.svg)](https://github.com/electron/asar/actions/workflows/test.yml)
44
[![npm version](http://img.shields.io/npm/v/@electron/asar.svg)](https://npmjs.org/package/@electron/asar)
55

66
Asar is a simple extensive archive format, it works like `tar` that concatenates

package.json

+3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
"bugs": {
2424
"url": "https://github.com/electron/asar/issues"
2525
},
26+
"publishConfig": {
27+
"provenance": true
28+
},
2629
"scripts": {
2730
"build": "tsc",
2831
"mocha": "xvfb-maybe electron-mocha --reporter spec && mocha --reporter spec",

test/api-spec.js

+41-32
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const rimraf = require('rimraf');
99
const asar = require('..');
1010
const compDirs = require('./util/compareDirectories');
1111
const compFileLists = require('./util/compareFileLists');
12-
const compFiles = require('./util/compareFiles');
12+
const { compFiles, isSymbolicLinkSync } = require('./util/compareFiles');
1313
const transform = require('./util/transformStream');
1414

1515
async function assertPackageListEquals(actualList, expectedFilename) {
@@ -107,38 +107,47 @@ describe('api', function () {
107107
asar.extractAll('test/input/extractthis-unpack-dir.asar', 'tmp/extractthis-unpack-dir-api/');
108108
return compDirs('tmp/extractthis-unpack-dir-api/', 'test/expected/extractthis');
109109
});
110-
it('should extract an archive with symlink', async () => {
111-
await asar.createPackageWithOptions(
112-
'test/input/packthis-with-symlink/',
113-
'tmp/packthis-with-symlink.asar',
114-
{ dot: false },
115-
);
116-
asar.extractAll('tmp/packthis-with-symlink.asar', 'tmp/packthis-with-symlink/');
117-
return compFiles(
118-
'tmp/packthis-with-symlink/real.txt',
119-
'test/input/packthis-with-symlink/real.txt',
120-
);
121-
});
122-
it('should extract an archive with symlink having the same prefix', async () => {
123-
await asar.createPackageWithOptions(
124-
'test/input/packthis-with-symlink-same-prefix/',
125-
'tmp/packthis-with-symlink-same-prefix.asar',
126-
{ dot: false },
127-
);
128-
asar.extractAll(
129-
'tmp/packthis-with-symlink-same-prefix.asar',
130-
'tmp/packthis-with-symlink-same-prefix/',
131-
);
132-
return compFiles(
133-
'tmp/packthis-with-symlink-same-prefix/real.txt',
134-
'test/input/packthis-with-symlink-same-prefix/real.txt',
135-
);
136-
});
137-
it('should not extract an archive with a bad symlink', async () => {
138-
assert.throws(() => {
139-
asar.extractAll('test/input/bad-symlink.asar', 'tmp/bad-symlink/');
110+
111+
// We don't extract symlinks on Windows, so skip these tests
112+
if (os.platform() !== 'win32') {
113+
it('should extract an archive with symlink', async () => {
114+
assert.strictEqual(isSymbolicLinkSync('test/input/packthis-with-symlink/real.txt'), true);
115+
await asar.createPackageWithOptions(
116+
'test/input/packthis-with-symlink/',
117+
'tmp/packthis-with-symlink.asar',
118+
{ dot: false },
119+
);
120+
asar.extractAll('tmp/packthis-with-symlink.asar', 'tmp/packthis-with-symlink/');
121+
return compFiles(
122+
'tmp/packthis-with-symlink/real.txt',
123+
'test/input/packthis-with-symlink/real.txt',
124+
);
140125
});
141-
});
126+
it('should extract an archive with symlink having the same prefix', async () => {
127+
assert.strictEqual(
128+
isSymbolicLinkSync('test/input/packthis-with-symlink-same-prefix/real.txt'),
129+
true,
130+
);
131+
await asar.createPackageWithOptions(
132+
'test/input/packthis-with-symlink-same-prefix/',
133+
'tmp/packthis-with-symlink-same-prefix.asar',
134+
{ dot: false },
135+
);
136+
asar.extractAll(
137+
'tmp/packthis-with-symlink-same-prefix.asar',
138+
'tmp/packthis-with-symlink-same-prefix/',
139+
);
140+
return compFiles(
141+
'tmp/packthis-with-symlink-same-prefix/real.txt',
142+
'test/input/packthis-with-symlink-same-prefix/real.txt',
143+
);
144+
});
145+
it('should not extract an archive with a bad symlink', async () => {
146+
assert.throws(() => {
147+
asar.extractAll('test/input/bad-symlink.asar', 'tmp/bad-symlink/');
148+
});
149+
});
150+
}
142151
it('should handle multibyte characters in paths', async () => {
143152
await asar.createPackageWithOptions(
144153
'test/input/packthis-unicode-path/',

test/cli-spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const rimraf = require('rimraf');
1010

1111
const compDirs = require('./util/compareDirectories');
1212
const compFileLists = require('./util/compareFileLists');
13-
const compFiles = require('./util/compareFiles');
13+
const { compFiles } = require('./util/compareFiles');
1414
const createSymlinkApp = require('./util/createSymlinkApp');
1515

1616
const exec = promisify(childProcess.exec);

test/util/compareFiles.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
const assert = require('assert');
44
const fs = require('../../lib/wrapped-fs').default;
55

6-
module.exports = async function (actualFilePath, expectedFilePath) {
6+
async function compFiles(actualFilePath, expectedFilePath) {
77
if (process.env.ELECTRON_ASAR_SPEC_UPDATE) {
88
await fs.writeFile(expectedFilePath, await fs.readFile(actualFilePath));
99
}
@@ -26,9 +26,11 @@ module.exports = async function (actualFilePath, expectedFilePath) {
2626
];
2727
assert.strictEqual(actualSymlinkPointer, expectedSymlinkPointer);
2828
}
29-
};
29+
}
3030

3131
function isSymbolicLinkSync(path) {
3232
const stats = fs.lstatSync(path);
3333
return stats.isSymbolicLink();
3434
}
35+
36+
module.exports = { compFiles, isSymbolicLinkSync };

0 commit comments

Comments
 (0)