Skip to content

Commit

Permalink
Add CI, fix for newer nim versions
Browse files Browse the repository at this point in the history
  • Loading branch information
OldhamMade committed Dec 25, 2020
1 parent 7316869 commit 810e094
Show file tree
Hide file tree
Showing 6 changed files with 172 additions and 47 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: CI

on:
push:
# CI shouldn't need to run on the main branch,
# just working & PR branches
branches-ignore:
- main
- master

jobs:
test:
strategy:
fail-fast: false
max-parallel: 20
matrix:
branch: [master]
target:
- nim_version: 1.2.8
os: linux
- nim_version: 1.4.2
os: linux
- nim_version: 1.2.8
os: macos
- nim_version: 1.4.2
os: macos
include:
- target:
os: linux
builder: ubuntu-18.04
- target:
os: macos
builder: macos-10.15

name: '${{ matrix.target.os }}-nim${{ matrix.target.nim_version }} (${{ matrix.branch }})'
runs-on: ${{ matrix.builder }}

steps:
- name: "[Git] Checkout code"
uses: actions/checkout@v2
- name: "[Setup] Configure caching"
uses: actions/cache@v2
with:
path: |
~/.asdf
key: ${{ matrix.target.os }}-nim${{ matrix.target.nim_version }}-${{ hashFiles('**/lockfiles') }}
- name: "[Setup] Install deps"
if: runner.os == 'Linux'
run: |
sudo apt-fast update -qq
sudo apt-fast --no-install-recommends -yq install curl git
- name: "[Setup] Install asdf"
run: |
[ -d ~/.asdf ] || git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.8.0
- name: "[Setup] Install nim dependencies"
run: |
source $HOME/.asdf/asdf.sh
[ -e $(asdf plugin list|grep nim) ] && asdf plugin add nim
asdf install nim ${{ matrix.target.nim_version }}
- name: "[Test] Run tests"
run: |
source $HOME/.asdf/asdf.sh
asdf info
asdf global nim ${{ matrix.target.nim_version }}
make test
45 changes: 45 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Create Release

on:
# Trigger this workflow on push (merge) events,
# but only for the main branch
push:
branches:
- main
- master

jobs:
release:
name: Create Release
runs-on: ubuntu-latest

steps:
- name: "[Git] Checkout code"
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: "[Version] Install"
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: '5.x'

- name: "[Version] Calculate"
id: gitversion # step id used as reference for output values
uses: gittools/actions/gitversion/[email protected]

- name: "[Version] Capture"
run: echo "RELEASE_VERSION=${{ steps.gitversion.outputs.semVer }}" >> $GITHUB_ENV

- name: "[Release] Create"
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{env.RELEASE_VERSION}}
release_name: ${{env.RELEASE_VERSION}}
body: |
Please see the changelog for details of this release
draft: false
prerelease: false
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -562,3 +562,4 @@ nimcache/
/ll
/src/ll
profile_results.txt
/tests/all.*/
Expand Down
42 changes: 17 additions & 25 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,40 +1,32 @@
define usage
Options:
build development build
test run test suite
fulltest run test suite within a local Travis-CI container
release release build, optimised for speed
install build a release version then mv to /usr/local/bin
clean remove build artefacts
endef
export usage

.PHONY: all release build test profile clean help

all: test
all: release

build:
build: ## development build
@nim c src/ll.nim

test:
@nimble test
test: ## run test suite
@nimble -y test --verbose

profile:
profile: ## run profiler
@nimble profile

fulltest:
@docker-compose -f .docker-compose.yml up --build

release:
@nimble build --nilseqs:on --verbose --opt:speed -d:release # --passC:-Ofast --threads:off --threadanalysis:off
release: ## release build, optimised for speed
@nimble -y build --nilseqs:on --verbose --opt:speed -d:release # --passC:-Ofast --threads:off --threadanalysis:off

install: release
install: release ## create a release build and install to /usr/local/bin
@mv ./ll /usr/local/bin/ll

clean:
clean: ## remove build artefacts
@find . -type d -iname 'nimcache' | xargs rm -rf
@rm -f ll
@rm -f src/ll

help:
@echo "$$usage"
help: ## display this help
@echo "Options:"
@grep -E '^[a-zA-Z%_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-18s\033[0m %s\n", $$1, $$2}'
@grep -E '^[a-zA-Z%_-]+:.*?##@deprecated.*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?##@deprecated "}; {printf " \033[31m%-18s\033[0m [deprecated] %s\n", $$1, $$2}'

# catch-all
%:
@:
61 changes: 40 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `ll` - a more informative `ls`, based on [`k`][1]

[![Travis Build][9]][10]
![CI](https://github.com/OldhamMade/ll/workflows/CI/badge.svg)


## Description
Expand Down Expand Up @@ -74,15 +74,14 @@ and install using the following instructions.

### Requirements

- [Nim][3], minimum v0.20.0
- [Nim][3], minimum v1.2.*
- `make`

### Steps

Firstly install [Nim][3]. You'll need to install version 0.20 as a
minimum. I personally use [`asdf`][6] to manage Nim versions on my
machine. With `asdf` installed, this is as simple as calling `asdf
install nim v0.20.0`.
Firstly install [Nim][3]. I personally use [`asdf`][6] to manage Nim
versions on my machine. With `asdf` installed, this is as simple as
calling `asdf install nim latest`.

Once Nim is installed, clone this repository. From within the cloned
directory, call `make install` which will build `ll` into the working
Expand All @@ -94,17 +93,6 @@ directory and will then opy the resulting `ll` binary to `/usr/local/bin`.

That's it. For more options, pass `-?` or `--help`.

## Development

`ll` is developed using Github issues and [Kanban][4]. If you would
like to request a feature or report a bug, please add a new issue
[here](https://github.com/OldhamMade/ll/issues) and we'll do our best
to address them. Please note that this is not a funded project and
fixes will be addressed on a best-effort basis.

Contributions and pull-requests are always welcome, as is constructive
feedback around code structure, hints, tips, etc.

## Status

- [x] Full file listing
Expand Down Expand Up @@ -140,13 +128,44 @@ over. If any other enhancements are added, I hope to port those also.
I'd like to display some additional information in the summary line of
the listing; I'm currently reviewing what would be most useful.

## Contributing

Contributions and pull-requests are always welcome, as is constructive
feedback around code structure, hints, tips, etc.

If you would like to request a feature or report a bug, please add a
new issue [here](https://github.com/OldhamMade/ll/issues) and we'll do
our best to address them. Please note that this is not a funded
project and fixes will be addressed on a best-effort basis.

To contribute directly:

1. Fork it (https://github.com/OldhamMade/ll/fork)
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new pull request

## Liability

We take no responsibility for the use of this tool, or external
instances provided by third parties. We strongly recommend you abide
by the valid official regulations in your country. Furthermore, we
refuse liability for any inappropriate or malicious use of this
tool. This tool is provided to you in the spirit of free, open
software.

You may view the LICENSE in which this software is provided to you
[here](./LICENSE).

> IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
> CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
> TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
> SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

[1]: https://github.com/supercrabtree/k
[2]: https://en.wikipedia.org/wiki/Z_shell
[3]: https://nim-lang.org
[4]: https://en.wikipedia.org/wiki/Kanban
[6]: https://github.com/asdf-vm/asdf
[7]: https://badge.waffle.io/03e04bd3c5dd71dd392210b4479adccc.svg?columns=all
[8]: https://waffle.io/OldhamMade/ll
[9]: https://api.travis-ci.org/OldhamMade/ll.svg?branch=master
[10]: https://travis-ci.org/OldhamMade/ll
5 changes: 4 additions & 1 deletion tests/listing_tests.nim
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ proc setUpSymlinkListing() =
writeFile(tmpdir / $i, $i)

for pair in zip(toSeq(1..4), toSeq(5..9)):
createSymlink(tmpdir / $pair.a, tmpdir / $pair.b)
when (NimMajor, NimMinor) <= (1, 0):
createSymlink(tmpdir / $pair.a, tmpdir / $pair.b)
else:
createSymlink(tmpdir / $pair[0], tmpdir / $pair[1])

removeFile(tmpdir / "1")

Expand Down

0 comments on commit 810e094

Please sign in to comment.