Skip to content

Commit

Permalink
chore!: Switch from yarn to npm (#1226)
Browse files Browse the repository at this point in the history
chore(ci): Update setup-node action
chore(ci): Utilize npm dependency cache
  • Loading branch information
phated authored May 15, 2022
1 parent dad3749 commit 5ea9274
Show file tree
Hide file tree
Showing 13 changed files with 10,184 additions and 3,280 deletions.
45 changes: 17 additions & 28 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,39 +13,28 @@ jobs:
node-version: ["16"]

steps:
- name: Checkout project
uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v2.1.2
uses: actions/setup-node@v3.1.1
with:
node-version: ${{ matrix.node-version }}
check-latest: true

# Add yarn's bin to our PATH
- name: Setup environment (Unix)
if: matrix.os != 'windows-latest'
run: |
echo $(yarn global bin) >> $GITHUB_PATH
# Add yarn's bin to our PATH
- name: Setup environment (Windows)
if: matrix.os == 'windows-latest'
run: |
echo $(yarn global bin) | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
cache: 'npm'

# Adds `shx` globally for cross-platform shell commands
- name: Setup environment (All)
run: |
yarn global add shx
- name: Checkout project
uses: actions/checkout@v2
npm install -g shx
- name: Set up JS runner and CLI
run: |
yarn
npm ci
- name: Esy setup
run: |
yarn compiler prepare
npm run compiler prepare
- name: Esy cache
id: esy-cache
Expand All @@ -57,40 +46,40 @@ jobs:
- name: Import esy cache
if: steps.esy-cache.outputs.cache-hit == 'true'
run: |
yarn compiler import-dependencies
npm run compiler import-dependencies
shx rm -rf compiler/_export
- name: Build compiler
run: |
yarn compiler build
npm run compiler build
# Re-export dependencies if anything has changed or if it is the first time
- name: Build esy cache
if: steps.esy-cache.outputs.cache-hit != 'true'
run: |
yarn compiler export-dependencies
npm run compiler export-dependencies
- name: Run tests (native)
if: matrix.os != 'windows-latest'
run: |
yarn compiler test
npm run compiler test
- name: Run tests (js)
if: matrix.os != 'windows-latest'
run: |
yarn compiler test:js
npm run compiler test:js
- name: Check parser error messages exhaustiveness
run: |
yarn compiler parser:check-errors
npm run compiler parser:check-errors
# Formatting lint last because building is more important
- name: Run formatting lint
if: matrix.os != 'windows-latest'
run: |
yarn compiler check-format
yarn js-runner check-format
yarn cli check-format
npm run compiler check-format
npm run js-runner check-format
npm run cli check-format
# This is to test the CLI is working
- name: Log Grain version
Expand Down
26 changes: 13 additions & 13 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,28 @@ jobs:
stdlib_download_url: ${{ steps.stdlib-upload.outputs.browser_download_url }}
js-runner_download_url: ${{ steps.js-runner-upload.outputs.browser_download_url }}
steps:
- name: Checkout project
uses: actions/checkout@v2

# Many of these steps are the same as building the compiler for tests
- name: Setup Node.js
uses: actions/setup-node@v2.1.2
uses: actions/setup-node@v3.1.1
with:
node-version: "16"
check-latest: true
cache: 'npm'

- name: Setup environment
run: |
yarn config set prefix $(npm config get prefix)
yarn global add shx
- name: Checkout project
uses: actions/checkout@v2
npm install -g shx
- name: Set up JS runner and CLI
run: |
yarn
npm ci
- name: Esy setup
run: |
yarn compiler prepare
npm run compiler prepare
- name: Esy cache
id: esy-cache
Expand All @@ -64,19 +64,19 @@ jobs:
- name: Import esy cache
if: steps.esy-cache.outputs.cache-hit == 'true'
run: |
yarn compiler import-dependencies
npm run compiler import-dependencies
shx rm -rf compiler/_export
# Don't build grainc.exe, only the JS builds
# TODO(#589): Actually build the exe's these once users can install them locally
- name: Build compiler
run: |
yarn compiler build:js
npm run compiler build:js
# This will log a warning because we removed the grainc.exe file
- name: Build Binaries
run: |
yarn cli build-pkg --target win-x64,mac-x64,linux-x64
npm run cli build-pkg -- --target=win-x64,mac-x64,linux-x64
- name: Upload Binary (Windows)
uses: actions/upload-release-asset@v1
Expand Down Expand Up @@ -195,7 +195,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Setup NodeJS
uses: actions/setup-node@v2.1.2
uses: actions/setup-node@v3.1.1
with:
node-version: "16"
registry-url: "https://registry.npmjs.org"
Expand All @@ -213,7 +213,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Setup NodeJS
uses: actions/setup-node@v2.1.2
uses: actions/setup-node@v3.1.1
with:
node-version: "16"
registry-url: "https://registry.npmjs.org"
Expand Down
4 changes: 2 additions & 2 deletions .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ image:

tasks:
- init: |
yarn --pure-lockfile
yarn compiler build
npm ci
npm run compiler build
vscode:
extensions:
- ocamllabs.ocaml-platform
Expand Down
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=true
10 changes: 4 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ When working with the compiler, you'll want to install [esy](https://esy.sh/docs
Once you have the compiler building, the typical flow for development is to make changes in the `compiler` directory, then run:

```bash
yarn compiler build
yarn compiler test
npm run compiler build
npm run compiler test
```

It can sometimes be helpful to run small Grain programs directly to test some functionality without running the full test suite.
Expand All @@ -38,16 +38,14 @@ It can sometimes be helpful to run small Grain programs directly to test some fu
After making changes in the `js-runner` directory, run:

```bash
yarn js-runner build
yarn js-runner test
npm run js-runner build
npm run js-runner test
```

Once the JS runner has been built, it's the only one active. Grain programs that you run from the command line or the tests will use that version.

### Standard library

If you're only changing `.gr` stdlib files, you don't need to do anything special. Running the tests will automatically recompile all of the standard library files. If you change any of the AssemblyScript files in the `stdlib-external` directory of `stdlib`, you'll need to run `yarn stdlib build` to recompile them.

It's usually easiest to create a small Grain program that imports your library to try it out, like so:

```grain
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ COPY . /grain
WORKDIR /grain

# Build the compiler and CLI
RUN yarn --pure-lockfile && \
yarn compiler build
RUN npm ci && \
npm run compiler build

# Set up container environment
WORKDIR /
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile-slim
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ COPY . /grain
WORKDIR /grain

# Build the compiler and CLI
RUN yarn --pure-lockfile && \
yarn compiler build
RUN npm ci && \
npm run compiler build

# Remove build files
RUN rm -rf node_modules compiler/_esy
Expand All @@ -25,7 +25,7 @@ COPY --from=builder /grain /grain
WORKDIR /grain

# Link CLI in new image and restore only necessary node_modules
RUN NODE_ENV=production yarn --pure-lockfile
RUN NODE_ENV=production npm ci

# Set up container environment
WORKDIR /
Expand Down
14 changes: 3 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,27 +35,19 @@ For instructions on how to build Grain from source, please consult the [official
To build the JS runner:

```bash
yarn js-runner build
npm run js-runner build
```

To link the CLI:

```bash
yarn cli link
npm run cli link
```

To reset your compiler build:

```bash
yarn compiler clean
npm run compiler clean
```

To navigate tasks available in the system:

```bash
yarn run
```

This will display an interactive session where you can select the project and command you want.

Copyright ©️ 2017-2022 Philip Blair, Oscar Spencer, & contributors.
2 changes: 1 addition & 1 deletion cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"scripts": {
"clean": "del-cli 'bin/*.exe' 'bin/*.bc.js'",
"link": "yarn link",
"link": "npm link",
"format": "prettier --write .",
"check-format": "prettier --check .",
"test": "echo \"Error: no test specified\" && exit 1",
Expand Down
10 changes: 5 additions & 5 deletions compiler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,24 @@
"esy": "0.6.12"
},
"scripts": {
"link": "yarn link",
"link": "npm link",
"clean": "esy clean",
"prepare": "esy install",
"prebuild": "yarn workspace @grain/cli clean",
"prebuild": "npm run clean --workspace=@grain/cli",
"build": "esy",
"postbuild": "esy copy:exe",
"build:js": "esy b dune build @js --no-buffer",
"postbuild:js": "esy copy:js",
"pretest": "yarn build",
"pretest": "npm run build",
"test": "esy test",
"pretest:js": "yarn build:js",
"pretest:js": "npm run build:js",
"test:js": "esy test:js",
"format": "esy format",
"check-format": "esy check-format",
"parser:interpret": "esy b menhir src/parsing/parser.mly --unused-tokens --interpret",
"parser:interpret-error": "esy b menhir src/parsing/parser.mly --unused-tokens --interpret-error",
"parser:list-errors": "esy b menhir src/parsing/parser.mly --unused-tokens --list-errors > src/parsing/parser.messages.generated",
"parser:check-errors": "yarn parser:list-errors && esy b menhir src/parsing/parser.mly --unused-tokens --compare-errors src/parsing/parser.messages.generated --compare-errors src/parsing/parser.messages",
"parser:check-errors": "npm run parser:list-errors && esy b menhir src/parsing/parser.mly --unused-tokens --compare-errors src/parsing/parser.messages.generated --compare-errors src/parsing/parser.messages",
"import-dependencies": "esy import-dependencies _export",
"export-dependencies": "esy export-dependencies",
"build-dependencies": "esy build-dependencies"
Expand Down
Loading

0 comments on commit 5ea9274

Please sign in to comment.