Skip to content

Commit

Permalink
Update CI configuration, handle --color automatically.
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikekre committed Mar 17, 2022
1 parent 1c414b5 commit fb884b6
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 11 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ on:

jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ github.event_name }}
name: Julia ${{ matrix.version }} - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
version:
- '1.0'
- '1.6'
- '1'
- 'nightly'
os:
Expand All @@ -33,12 +33,12 @@ jobs:
julia --project -e 'using Pkg; Pkg.instantiate()'
julia --project -e 'using jlpkg; jlpkg.install(; command = "jlpkg-ci", destdir = joinpath(pwd(), "bin"))'
- name: "Run tests (Unix)"
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macOS-latest'
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
run: jlpkg-ci --project test --coverage
- name: "Run tests (Windows)"
if: matrix.os == 'windows-latest'
run: cmd /c jlpkg-ci --project test --coverage
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v1
- uses: codecov/codecov-action@v2
with:
file: lcov.info
files: lcov.info
4 changes: 3 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
Copyright (c) 2019-2021 Fredrik Ekre
MIT License

Copyright (c) 2019-2022 Fredrik Ekre

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 2 additions & 0 deletions src/jlpkg-completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

# Bash completion for jlpkg version 1.4.0.
# See https://github.com/fredrikekre/jlpkg for details.
# Copyright (c) 2019-2022 Fredrik Ekre
# SPDX-License-Identifier: MIT

# Notes to self:
# Uses
Expand Down
20 changes: 16 additions & 4 deletions src/jlpkg.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
# SPDX-License-Identifier: MIT

module jlpkg

# --compile=min segfaults Julia 1.0 and the fix can't trivially be backported.
# --color should be removed for the new LTS due to better defaults in Julia >1.5
@static if VERSION < v"1.1"
# --compile=min segfaults Julia 1.0 and the fix can't trivially be backported.
const default_julia_flags = ["--color=yes", "--startup-file=no", "-q", "-O0"]
else
elseif VERSION < v"1.6"
const default_julia_flags = ["--color=yes", "--startup-file=no", "-q", "--compile=min", "-O0"]
else
# --color handling is automatic for Julia >1.5
const default_julia_flags = ["--startup-file=no", "-q", "--compile=min", "-O0"]
end

"""
Expand All @@ -20,7 +24,7 @@ Install the command line interface.
- `destdir`: writable directory (available in PATH) for the executable,
defaults to `~/.julia/bin`.
- `julia_flags`: vector with command line flags for the julia executable,
defaults to `["--color=yes", "--startup-file=no", "-q", "--compile=min", "-O0"]`.
defaults to `$(default_julia_flags)`.
- `force`: boolean used to overwrite any existing commands.
"""
function install(; julia::String=joinpath(Sys.BINDIR, Base.julia_exename()),
Expand All @@ -39,15 +43,23 @@ function install(; julia::String=joinpath(Sys.BINDIR, Base.julia_exename()),
if Sys.iswindows()
# TODO: Find a way to embed the script in the file
print(f, """
:: Copyright (c) 2019-2022 Fredrik Ekre
:: SPDX-License-Identifier: MIT
@ECHO OFF
$(julia) $(join(julia_flags, ' ')) $(abspath(@__DIR__, "cli.jl")) %*
""")
else # unix
print(f, """
#!/usr/bin/env bash
# Copyright (c) 2019-2022 Fredrik Ekre
# SPDX-License-Identifier: MIT
#=
exec $(julia) $(join(julia_flags, ' ')) "\${BASH_SOURCE[0]}" "\$@"
=#
""")
open(abspath(@__DIR__, "cli.jl"), "r") do cli
write(f, cli)
Expand Down
5 changes: 4 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# SPDX-License-Identifier: MIT

using jlpkg, Test, Pkg, Pkg.TOML

const root = joinpath(dirname(dirname(pathof(jlpkg))))
# --compile=yes required due to JuliaLang/julia#37059
# --code_coverage=@ replaced with "user"
const test_cmd = ```$(Base.julia_cmd()) $(jlpkg.default_julia_flags)
--code-coverage=$(["none", "user", "all"][Base.JLOptions().code_coverage+1])
--code-coverage=$(cc = Base.JLOptions().code_coverage; cc == 0 ? "user" : cc == 2 ? "all" : "user")
--compile=yes
--color=no
$(joinpath(root, "src", "cli.jl"))```
Expand Down

0 comments on commit fb884b6

Please sign in to comment.