Skip to content

Commit

Permalink
Setup GitHub actions
Browse files Browse the repository at this point in the history
  • Loading branch information
andywhite37 committed Dec 12, 2019
1 parent e8e1cc4 commit 8bbc0b2
Show file tree
Hide file tree
Showing 7 changed files with 1,679 additions and 880 deletions.
42 changes: 0 additions & 42 deletions .circleci/config.yml

This file was deleted.

41 changes: 41 additions & 0 deletions .github/workflows/ci.yml
@@ -0,0 +1,41 @@
name: CI

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [12.x]

steps:
- name: Checkout
uses: actions/checkout@v1

- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

# TODO: not sure if this actually does anything useful
- name: Cache ~/.npm
uses: actions/cache@v1
with:
path: ~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-
- name: npm install
run: npm install

- name: npm run cleancoverage
run: npm run cleancoverage

- name: Coveralls
uses: coverallsapp/github-action@master
with:
path-to-lcov: ./docs/coverage/lcov.info
github-token: ${{ secrets.GITHUB_TOKEN }}
9 changes: 5 additions & 4 deletions .gitignore
Expand Up @@ -5,10 +5,11 @@ node_modules/
.bsb.lock
.merlin

# Parcel
dist/
.cache/

# Project
lib/bs/
*.bs.js

# Parcel
dist/
.cache/
/docs/coverage
2 changes: 1 addition & 1 deletion README.md
@@ -1,6 +1,6 @@
# relude-fetch

[![CircleCI](https://img.shields.io/circleci/project/github/reazen/relude-fetch/master.svg)](https://circleci.com/gh/reazen/relude-fetch)
[![GitHub CI](https://img.shields.io/github/workflow/status/reazen/relude-fetch/CI/master)](https://github.com/reazen/relude-fetch/actions)
[![npm](https://img.shields.io/npm/v/relude-fetch.svg)](https://www.npmjs.com/package/relude-fetch)

## Overview
Expand Down
65 changes: 34 additions & 31 deletions examples/demo/FileUploadDemo.re
Expand Up @@ -31,7 +31,7 @@ module API = {
// This call fails, but you can inspect the request in the dev tools to see that it has the
// multi-part encoded form data.
ReludeFetch.fetchWith(
~method_=Fetch.Post,
~method__=Fetch.Post,
~body=FormData(formData),
"/fake-upload-file",
)
Expand Down Expand Up @@ -72,36 +72,39 @@ let onSubmit = (send: action => unit, event: ReactEvent.Form.t): unit => {
[@react.component]
let make = () => {
let (state, send) =
ReludeReact.Reducer.useReducer(initialState, (action, state) =>
switch (action) {
| SetFile(file) =>
Update({
file: Some(file),
message: Some("Selected file: " ++ (file |> File.name)),
})

| Submit =>
switch (state.file) {
| None => Update({...state, message: Some("No file selected")})
| Some(file) =>
UpdateWithIO(
{
...state,
message: Some("Uploading file: " ++ (file |> File.name)),
},
API.uploadFile(file)
|> IO.bimap(_ => SubmitSuccess, error => SubmitFailure(error)),
)
}

| SubmitSuccess => Update({...state, message: Some("Upload success!")})

| SubmitFailure(error) =>
Update({
...state,
message: Some("Upload error: " ++ API.Error.show(error)),
})
}
ReludeReact.Reducer.useReducer(
(state, action) =>
switch (action) {
| SetFile(file) =>
Update({
file: Some(file),
message: Some("Selected file: " ++ (file |> File.name)),
})

| Submit =>
switch (state.file) {
| None => Update({...state, message: Some("No file selected")})
| Some(file) =>
UpdateWithIO(
{
...state,
message: Some("Uploading file: " ++ (file |> File.name)),
},
API.uploadFile(file)
|> IO.bimap(_ => SubmitSuccess, error => SubmitFailure(error)),
)
}

| SubmitSuccess =>
Update({...state, message: Some("Upload success!")})

| SubmitFailure(error) =>
Update({
...state,
message: Some("Upload error: " ++ API.Error.show(error)),
})
},
initialState,
);

<div>
Expand Down

0 comments on commit 8bbc0b2

Please sign in to comment.