Skip to content

Commit 6c7ec7d

Browse files
author
BSKY
authored
Merge pull request #19 from imbsky/prettier
Add prettier and some improvements
2 parents f200c04 + 432a8a4 commit 6c7ec7d

File tree

13 files changed

+650
-529
lines changed

13 files changed

+650
-529
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
* text=auto eol=lf
12
lib/* linguist-generated

.github/workflows/test.yml

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,40 @@
11
name: Test ocaml-action
22

33
on:
4-
push:
5-
branches:
6-
- "master"
7-
- "releases/*"
8-
pull_request:
4+
- push
5+
- pull_request
96

107
jobs:
118
test:
129
strategy:
1310
fail-fast: false
1411
matrix:
15-
os: [ubuntu-latest, macos-latest, windows-latest]
16-
ocaml-version: ["4.08.1", "4.05.0"]
12+
os:
13+
- macos-latest
14+
- ubuntu-latest
15+
- windows-latest
16+
node-version:
17+
- 13.x
18+
ocaml-version:
19+
- 4.08.1
20+
- 4.05.0
1721

1822
runs-on: ${{ matrix.os }}
1923

2024
steps:
2125
- name: Checkout code
22-
uses: actions/checkout@v2
26+
uses: actions/[email protected]
27+
28+
- name: Use Node.js ${{ matrix.node-version }}
29+
uses: actions/[email protected]
30+
with:
31+
node-version: ${{ matrix.node-version }}
32+
33+
- name: Install npm packages
34+
run: yarn --frozen-lockfile
35+
36+
- name: Check formatting
37+
run: yarn fmt:check
2338

2439
- name: Use OCaml ${{ matrix.ocaml-version }}
2540
uses: ./

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
lib/

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# Create an OCaml Action
1+
# Create an OCaml Action
22

33
Use this template to bootstrap the creation of an OCaml action.:rocket:
44

55
This template installs the [opam](https://opam.ocaml.org) on Ubuntu Linux,
66
macOS and Windows for use with GitHub Actions.
77

8-
If you are new, there's also a simpler introduction. See the [Hello World
8+
If you are new, there's also a simpler introduction. See the [Hello World
99
OCaml Action](https://github.com/avsm/hello-world-action-ocaml) that uses Dune
1010
and opam to build a simple library.
1111

@@ -17,19 +17,19 @@ and opam to build a simple library.
1717

1818
The action does the following:
1919

20-
- *Ubuntu:* Installs the latest opam with sandboxing active
21-
- *macOS:* Installs the latest opam from Homebrew with sandboxing active
22-
- *Windows:* Installs Cygwin and the [fdopen fork](https://fdopen.github.io/opam-repository-mingw/) with mingw64c
20+
- _Ubuntu:_ Installs the latest opam with sandboxing active
21+
- _macOS:_ Installs the latest opam from Homebrew with sandboxing active
22+
- _Windows:_ Installs Cygwin and the [fdopen fork](https://fdopen.github.io/opam-repository-mingw/) with mingw64c
2323

2424
The repository is initialised to the default one, and then the following plugins are installed:
25+
2526
- `opam-depext`
2627

2728
The `opam` binary is added to the `PATH` for subsequent actions, so that
2829
executing `opam` commands will just work after that.
2930

3031
## Example workflow
3132

32-
3333
```
3434
name: Build Hello World executable
3535
on: [push, pull_request]
@@ -59,7 +59,7 @@ jobs:
5959
## Roadmap
6060

6161
This action aims to provide an OS-neutral interface to `opam`, and so
62-
will not add features that only work on one operating system. It will
62+
will not add features that only work on one operating system. It will
6363
also track the latest stable release of opam.
6464

6565
Discussions: https://discuss.ocaml.org/t/github-actions-for-ocaml-opam-now-available/4745

__tests__/installer.test.ts

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,14 @@
1-
import io = require('@actions/io');
2-
import fs = require('fs');
3-
import os = require('os');
4-
import path = require('path');
1+
import * as io from "@actions/io";
2+
import * as path from "path";
3+
import * as installer from "../src/installer";
54

6-
const toolDir = path.join(__dirname, 'runner', 'tools');
7-
const tempDir = path.join(__dirname, 'runner', 'temp');
8-
const dataDir = path.join(__dirname, 'data');
5+
const toolDir = path.join(__dirname, "runner", "tools");
6+
const tempDir = path.join(__dirname, "runner", "temp");
97

10-
process.env['RUNNER_TOOL_CACHE'] = toolDir;
11-
process.env['RUNNER_TEMP'] = tempDir;
12-
import * as installer from '../src/installer';
13-
14-
const IS_WINDOWS = process.platform === 'win32';
15-
16-
describe('installer tests', () => {
8+
process.env["RUNNER_TOOL_CACHE"] = toolDir;
9+
process.env["RUNNER_TEMP"] = tempDir;
1710

11+
describe("installer tests", () => {
1812
beforeAll(async () => {
1913
await io.rmRF(toolDir);
2014
await io.rmRF(tempDir);
@@ -25,13 +19,11 @@ describe('installer tests', () => {
2519
await io.rmRF(toolDir);
2620
await io.rmRF(tempDir);
2721
} catch {
28-
console.log('Failed to remove test directories');
22+
console.log("Failed to remove test directories");
2923
}
3024
}, 100000);
3125

32-
it('Acquires opam source', async () => {
33-
await installer.getOpam('2.0.5');
34-
const OCamldir = path.join(toolDir, 'opam', '2.0.5', os.arch());
26+
it("Acquires opam source", async () => {
27+
await installer.getOpam("2.0.5");
3528
}, 1000000);
36-
3729
});

action.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ name: Set up OCaml
22
description: Set up an OCaml and opam environment and add to PATH
33
author: Anil Madhavapeddy
44
branding:
5-
icon: 'package'
6-
color: 'orange'
5+
icon: "package"
6+
color: "orange"
77
inputs:
88
ocaml-version:
99
description: Version of the OCaml compiler to initialise
1010
default: 4.08.1
1111
runs:
12-
using: 'node12'
13-
main: 'lib/index.js'
12+
using: "node12"
13+
main: "lib/index.js"

jest.config.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
module.exports = {
22
clearMocks: true,
3-
moduleFileExtensions: ['js', 'ts'],
4-
testEnvironment: 'node',
5-
testMatch: ['**/*.test.ts'],
6-
testRunner: 'jest-circus/runner',
3+
moduleFileExtensions: ["js", "ts"],
4+
testEnvironment: "node",
5+
testMatch: ["**/*.test.ts"],
6+
testRunner: "jest-circus/runner",
77
transform: {
8-
'^.+\\.ts$': 'ts-jest'
8+
"^.+\\.ts$": "ts-jest",
99
},
10-
verbose: true
11-
}
10+
verbose: true,
11+
};

lib/index.js

Lines changed: 28 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{
22
"private": true,
33
"scripts": {
4+
"fmt": "prettier --write .",
5+
"fmt:check": "prettier --check .",
46
"test": "jest",
57
"build:copy": "mkdir -p lib && shx cp src/*.{bat,cmd,sh} lib/",
68
"build:setup-ocaml": "ncc build src/setup-ocaml.ts -o lib",
@@ -17,6 +19,7 @@
1719
"jest": "25.2.7",
1820
"jest-circus": "25.2.7",
1921
"npm-run-all": "4.1.5",
22+
"prettier": "2.0.4",
2023
"shx": "0.3.2",
2124
"ts-jest": "25.3.1",
2225
"typescript": "3.8.3"

0 commit comments

Comments
 (0)