Skip to content

Commit

Permalink
Merge pull request direnv#484 from direnv/azure-pipelines
Browse files Browse the repository at this point in the history
Set up CI with Azure Pipelines
  • Loading branch information
zimbatm authored Mar 31, 2019
2 parents 9f5ee3e + 51c3c44 commit a2cfbc9
Show file tree
Hide file tree
Showing 13 changed files with 129 additions and 48 deletions.
36 changes: 0 additions & 36 deletions .travis.yml

This file was deleted.

3 changes: 2 additions & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
DESTDIR ?= /usr/local
BINDIR = ${DESTDIR}/bin
MANDIR = ${DESTDIR}/share/man
DISTDIR ?= dist

# filename of the executable
exe = direnv$(shell go env GOEXE)
Expand Down Expand Up @@ -161,5 +162,5 @@ install: all
.PHONY: dist
dist: | $(base)
@command -v gox >/dev/null || (echo "Could not generate dist because gox is missing. Run: go get -u github.com/mitchellh/gox"; false)
cd "$(base)" && gox -output "dist/direnv.{{.OS}}-{{.Arch}}"
cd "$(base)" && gox -output "$(DISTDIR)/direnv.{{.OS}}-{{.Arch}}"

3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ direnv -- Unclutter your .profile
=================================

[![Built with Nix](https://builtwithnix.org/badge.svg)](https://builtwithnix.org)
[![Build Status](https://travis-ci.org/direnv/direnv.svg?branch=master)](https://travis-ci.org/direnv/direnv)

[![Build Status](https://dev.azure.com/direnv/direnv/_apis/build/status/direnv.direnv?branchName=master)](https://dev.azure.com/direnv/direnv/_build/latest?definitionId=1&branchName=master)
`direnv` is an environment switcher for the shell. It knows how to hook into
bash, zsh, tcsh, fish shell and elvish to load or unload environment variables
depending on the current directory. This allows project-specific
Expand Down
29 changes: 29 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# See https://aka.ms/yaml

trigger:
- master

jobs:
- job: Linux
pool:
vmImage: 'ubuntu-16.04'
steps:
- template: ci/build-steps.yml

- job: macOS
pool:
vmImage: 'macOS-10.13'
steps:
- template: ci/build-steps.yml

- job: Release
pool:
vmImage: 'ubuntu-16.04'
steps:
- template: ci/release-steps.yml

# - job: Windows
# pool:
# vmImage: 'windows-2019'
# steps:
# - template: azure-pipelines-windows.yml
19 changes: 19 additions & 0 deletions ci/build-steps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
steps:
- checkout: self
fetchDepth: 1
- bash: |
set -euo pipefail
curl -sfL https://nixos.org/nix/install | bash
displayName: 'Install Nix'
- bash: |
set -euo pipefail
MANPATH=
source $HOME/.nix-profile/etc/profile.d/nix.sh
nix-build
displayName: 'Build'
- bash: |
set -euo pipefail
MANPATH=
source $HOME/.nix-profile/etc/profile.d/nix.sh
nix-shell --pure --run "make test"
displayName: 'Test'
22 changes: 22 additions & 0 deletions ci/release-steps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
steps:
- checkout: self
fetchDepth: 1
- bash: |
set -euo pipefail
curl -sfL https://nixos.org/nix/install | bash
displayName: 'Install Nix'
- bash: |
set -euo pipefail
MANPATH=
source $HOME/.nix-profile/etc/profile.d/nix.sh
nix-shell --pure --run "make dist DISTDIR=$BUILD_ARTIFACTSTAGINGDIRECTORY"
displayName: 'Build static binaries'
- task: PublishBuildArtifacts@1
displayName: 'Publish static binaries'
inputs:
artifactName: direnv-bins
- task: GithubRelease@0
displayName: 'Create GitHub Release'
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/v')
inputs:
githubConnection: direnv-releases
3 changes: 2 additions & 1 deletion default.nix
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{ pkgs ? import <nixpkgs> {} }:
{ pkgs ? import ./nix {} }:
with pkgs;

buildGoPackage rec {
name = "direnv-${version}";
version = lib.fileContents ./version.txt;
goPackagePath = "github.com/direnv/direnv";
subPackages = ["."];

src = lib.cleanSource ./.;

Expand Down
5 changes: 5 additions & 0 deletions nix/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{ sources ? import ./sources.nix }:
import sources.nixpkgs {
config = {};
overlays = [];
}
12 changes: 12 additions & 0 deletions nix/sources.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"nixpkgs": {
"url": "https://github.com/nixos/nixpkgs-channels/archive/3a4ffdd38b56801ce616aa08791121d36769e884.tar.gz",
"owner": "nixos",
"branch": "nixos-19.03",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz",
"repo": "nixpkgs-channels",
"sha256": "1vfmmd88x4rmgrz95xzr67xpmp1cqbrk6cfdadxv8ifqk0gsbrm7",
"description": "Nixpkgs/NixOS branches that track the Nixpkgs/NixOS channels",
"rev": "3a4ffdd38b56801ce616aa08791121d36769e884"
}
}
29 changes: 29 additions & 0 deletions nix/sources.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# A record, from name to path, of the third-party packages
with
{
sources = builtins.fromJSON (builtins.readFile ./sources.json);

# fetchTarball version that is compatible between all the sources of Nix
fetchTarball =
{ url, sha256 }:
if builtins.lessThan builtins.nixVersion "1.12" then
builtins.fetchTarball { inherit url; }
else
builtins.fetchTarball { inherit url sha256; };
mapAttrs = builtins.mapAttrs or
(f: set: with builtins;
listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set)));
};

# NOTE: spec must _not_ have an "outPath" attribute
mapAttrs (_: spec:
if builtins.hasAttr "outPath" spec
then abort
"The values in sources.json should not have an 'outPath' attribute"
else
if builtins.hasAttr "url" spec && builtins.hasAttr "sha256" spec
then
spec //
{ outPath = fetchTarball { inherit (spec) url sha256; } ; }
else spec
) sources
2 changes: 1 addition & 1 deletion shell.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ pkgs ? import <nixpkgs> {} }:
{ pkgs ? import ./nix {} }:
with pkgs;
mkShell {
buildInputs = [
Expand Down
6 changes: 3 additions & 3 deletions stdlib.go
Original file line number Diff line number Diff line change
Expand Up @@ -587,13 +587,13 @@ const STDLIB = "#!/usr/bin/env bash\n" +
"rvm() {\n" +
" unset rvm\n" +
" if [[ -n ${rvm_scripts_path:-} ]]; then\n" +
" # shellcheck source=/dev/null\n" +
" # shellcheck disable=SC1090\n" +
" source \"${rvm_scripts_path}/rvm\"\n" +
" elif [[ -n ${rvm_path:-} ]]; then\n" +
" # shellcheck source=/dev/null\n" +
" # shellcheck disable=SC1090\n" +
" source \"${rvm_path}/scripts/rvm\"\n" +
" else\n" +
" # shellcheck source=/dev/null\n" +
" # shellcheck disable=SC1090\n" +
" source \"$HOME/.rvm/scripts/rvm\"\n" +
" fi\n" +
" rvm \"$@\"\n" +
Expand Down
8 changes: 4 additions & 4 deletions stdlib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ source_env() {
pushd "$(dirname "$rcpath")" >/dev/null
if [[ -f ./$(basename "$rcpath") ]]; then
log_status "loading $rcfile"
# shellcheck source=/dev/null
# shellcheck disable=SC1090
. "./$(basename "$rcpath")"
else
log_status "referenced $rcfile does not exist"
Expand Down Expand Up @@ -585,13 +585,13 @@ use_rbenv() {
rvm() {
unset rvm
if [[ -n ${rvm_scripts_path:-} ]]; then
# shellcheck source=/dev/null
# shellcheck disable=SC1090
source "${rvm_scripts_path}/rvm"
elif [[ -n ${rvm_path:-} ]]; then
# shellcheck source=/dev/null
# shellcheck disable=SC1090
source "${rvm_path}/scripts/rvm"
else
# shellcheck source=/dev/null
# shellcheck disable=SC1090
source "$HOME/.rvm/scripts/rvm"
fi
rvm "$@"
Expand Down

0 comments on commit a2cfbc9

Please sign in to comment.