Skip to content

Commit 4b6a381

Browse files
CI: setup eslint & fix linter issues
1 parent 4a567db commit 4b6a381

File tree

13 files changed

+7025
-1646
lines changed

13 files changed

+7025
-1646
lines changed

.github/workflows/flatpak-test.yml

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ jobs:
1818
bundle: org.example.MyApp.Devel.flatpak
1919
manifest-path: ./flatpak-builder/tests/test-project/org.example.MyApp.yaml
2020
cache-key: flatpak-builder-${{ github.sha }}
21-
- uses: ./flat-manager
22-
with:
23-
repository: elementary
24-
flat-manager-url: https://flatpak-api.elementary.io
25-
token: some_very_hidden_token
21+
# TODO: setup a flat-manager before and use it later here
22+
#- uses: ./flat-manager
23+
# with:
24+
# repository: elementary
25+
# flat-manager-url: https://flatpak-api.elementary.io
26+
# token: some_very_hidden_token
2627

2728
tests:
2829
name: Tests
@@ -36,7 +37,25 @@ jobs:
3637
uses: actions/setup-node@v1
3738
with:
3839
node-version: ${{ matrix.node-version }}
39-
- run: npm install --also=dev
40+
- run: yarn install --also=dev
41+
working-directory: flatpak-builder
42+
- run: yarn test
43+
working-directory: flatpak-builder
44+
45+
eslint:
46+
name: Lint
47+
runs-on: ubuntu-latest
48+
steps:
49+
- uses: actions/checkout@v2
50+
- name: Use Node.js 14
51+
uses: actions/setup-node@v1
52+
with:
53+
node-version: "14"
54+
- run: yarn install --also=dev
4055
working-directory: flatpak-builder
41-
- run: npm test
56+
- run: yarn run eslint .
4257
working-directory: flatpak-builder
58+
- run: yarn install --also=dev
59+
working-directory: flat-manager
60+
- run: yarn run eslint .
61+
working-directory: flat-manager

flat-manager/.eslintrc.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"ignorePatterns": ["dist"],
3+
"env": {
4+
"commonjs": true,
5+
"es2021": true,
6+
"node": true
7+
},
8+
"extends": [
9+
"standard"
10+
],
11+
"parserOptions": {
12+
"ecmaVersion": 12
13+
}
14+
}

flat-manager/dist/index.js

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -9,57 +9,57 @@ const core = __webpack_require__(699)
99
const exec = __webpack_require__(922)
1010

1111
// FIXME: get this from the outputs of the flatpak-builder action
12-
const LOCAL_REPO_NAME = "repo"
13-
12+
const LOCAL_REPO_NAME = 'repo'
1413

1514
const run = (repository, flatManagerUrl, token) => {
16-
exec.exec('flatpak', [
17-
'build-update-repo',
18-
'--generate-static-deltas',
19-
LOCAL_REPO_NAME,
20-
])
15+
exec.exec('flatpak', [
16+
'build-update-repo',
17+
'--generate-static-deltas',
18+
LOCAL_REPO_NAME
19+
])
2120
.then(async () => {
22-
const buildId = await exec.exec('flat-manager-client', [
23-
'--token',
24-
token,
25-
'create',
26-
flatManagerUrl,
27-
repository,
28-
])
29-
return buildId
21+
const buildId = await exec.exec('flat-manager-client', [
22+
'--token',
23+
token,
24+
'create',
25+
flatManagerUrl,
26+
repository
27+
])
28+
return buildId
3029
})
3130
.then(async (buildId) => {
32-
await exec.exec('flat-manager-client', [
33-
'--token',
34-
token,
35-
'push',
36-
'--commit',
37-
'--publish',
38-
'--wait',
39-
buildId,
40-
LOCAL_REPO_NAME,
41-
])
42-
return buildId
31+
await exec.exec('flat-manager-client', [
32+
'--token',
33+
token,
34+
'push',
35+
'--commit',
36+
'--publish',
37+
'--wait',
38+
buildId,
39+
LOCAL_REPO_NAME
40+
])
41+
return buildId
4342
})
4443
.then(async (buildId) => {
45-
await exec.exec('flat-manager-client', [
46-
'purge',
47-
buildId,
48-
])
44+
await exec.exec('flat-manager-client', [
45+
'purge',
46+
buildId
47+
])
4948
})
5049
.catch((err) => {
51-
core.setFailed(`Failed to publish the build: ${err}`)
50+
core.setFailed(`Failed to publish the build: ${err}`)
5251
})
5352
}
5453

5554
if (require.main === require.cache[eval('__filename')]) {
56-
run(
57-
core.getInput('repository'),
58-
core.getInput('flat-manager-url'),
59-
core.getInput('token')
60-
)
55+
run(
56+
core.getInput('repository'),
57+
core.getInput('flat-manager-url'),
58+
core.getInput('token')
59+
)
6160
}
6261

62+
6363
/***/ }),
6464

6565
/***/ 96:

flat-manager/index.js

Lines changed: 38 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,53 @@
1-
const core = require("@actions/core")
2-
const exec = require("@actions/exec")
1+
const core = require('@actions/core')
2+
const exec = require('@actions/exec')
33

44
// FIXME: get this from the outputs of the flatpak-builder action
5-
const LOCAL_REPO_NAME = "repo"
6-
5+
const LOCAL_REPO_NAME = 'repo'
76

87
const run = (repository, flatManagerUrl, token) => {
9-
exec.exec('flatpak', [
10-
'build-update-repo',
11-
'--generate-static-deltas',
12-
LOCAL_REPO_NAME,
13-
])
8+
exec.exec('flatpak', [
9+
'build-update-repo',
10+
'--generate-static-deltas',
11+
LOCAL_REPO_NAME
12+
])
1413
.then(async () => {
15-
const buildId = await exec.exec('flat-manager-client', [
16-
'--token',
17-
token,
18-
'create',
19-
flatManagerUrl,
20-
repository,
21-
])
22-
return buildId
14+
const buildId = await exec.exec('flat-manager-client', [
15+
'--token',
16+
token,
17+
'create',
18+
flatManagerUrl,
19+
repository
20+
])
21+
return buildId
2322
})
2423
.then(async (buildId) => {
25-
await exec.exec('flat-manager-client', [
26-
'--token',
27-
token,
28-
'push',
29-
'--commit',
30-
'--publish',
31-
'--wait',
32-
buildId,
33-
LOCAL_REPO_NAME,
34-
])
35-
return buildId
24+
await exec.exec('flat-manager-client', [
25+
'--token',
26+
token,
27+
'push',
28+
'--commit',
29+
'--publish',
30+
'--wait',
31+
buildId,
32+
LOCAL_REPO_NAME
33+
])
34+
return buildId
3635
})
3736
.then(async (buildId) => {
38-
await exec.exec('flat-manager-client', [
39-
'purge',
40-
buildId,
41-
])
37+
await exec.exec('flat-manager-client', [
38+
'purge',
39+
buildId
40+
])
4241
})
4342
.catch((err) => {
44-
core.setFailed(`Failed to publish the build: ${err}`)
43+
core.setFailed(`Failed to publish the build: ${err}`)
4544
})
4645
}
4746

4847
if (require.main === module) {
49-
run(
50-
core.getInput('repository'),
51-
core.getInput('flat-manager-url'),
52-
core.getInput('token')
53-
)
54-
}
48+
run(
49+
core.getInput('repository'),
50+
core.getInput('flat-manager-url'),
51+
core.getInput('token')
52+
)
53+
}

flat-manager/package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
{
22
"name": "flat-manager",
3-
"version": "1.0.0",
43
"main": "index.js",
54
"license": "MIT",
65
"dependencies": {
76
"@actions/core": "^1.2.7",
87
"@actions/exec": "^1.0.4"
8+
},
9+
"devDependencies": {
10+
"eslint": "^7.24.0",
11+
"eslint-config-standard": "^16.0.2",
12+
"eslint-plugin-import": "^2.22.1",
13+
"eslint-plugin-node": "^11.1.0",
14+
"eslint-plugin-promise": "^4.3.1",
15+
"jest": "^26.6.1"
916
}
1017
}

0 commit comments

Comments
 (0)