Skip to content

Commit

Permalink
Merge pull request #1413 from dsalaza4/main
Browse files Browse the repository at this point in the history
feat(cross): #1223 use jobs approach
  • Loading branch information
dsalaza4 authored Dec 19, 2024
2 parents 2dfeff8 + b507117 commit f23013d
Show file tree
Hide file tree
Showing 23 changed files with 146 additions and 129 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -340,21 +340,21 @@ jobs:
- name: /tests/makeTemplate
run: nix-env -if . && m . /tests/makeTemplate

linux_tests_scriptWithHelp:
linux_tests_makeScript:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@f095bcc56b7c2baf48f3ac70d6d6782f4f553222
- uses: docker://docker.io/nixos/nix@sha256:c3db4c484f6b1ee6c9bb8ca90307cfbeca8ef88156840911356a677eeaff4845
name: /tests/scriptWithHelp
name: /tests/makeScript
with:
args: sh -c "chown -R root:root /github/workspace && nix-env -if . && m . /tests/scriptWithHelp"
macos_tests_scriptWithHelp:
args: sh -c "chown -R root:root /github/workspace && nix-env -if . && m . /tests/makeScript"
macos_tests_makeScript:
runs-on: macos-latest
steps:
- uses: actions/checkout@f095bcc56b7c2baf48f3ac70d6d6782f4f553222
- uses: cachix/install-nix-action@6ed004b9ccb68dbc28e7c85bee15fa93dbd214ac
- name: /tests/scriptWithHelp
run: nix-env -if . && m . /tests/scriptWithHelp
- name: /tests/makeScript
run: nix-env -if . && m . /tests/makeScript

linux_tests_secretsForGpgFromEnv:
runs-on: ubuntu-latest
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -496,23 +496,23 @@ jobs:
env:
CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }}

linux_tests_scriptWithHelp:
linux_tests_makeScript:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@f095bcc56b7c2baf48f3ac70d6d6782f4f553222
- uses: docker://docker.io/nixos/nix@sha256:c3db4c484f6b1ee6c9bb8ca90307cfbeca8ef88156840911356a677eeaff4845
name: /tests/scriptWithHelp
name: /tests/makeScript
with:
args: sh -c "chown -R root:root /github/workspace && nix-env -if . && m . /tests/scriptWithHelp"
args: sh -c "chown -R root:root /github/workspace && nix-env -if . && m . /tests/makeScript"
env:
CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }}
macos_tests_scriptWithHelp:
macos_tests_makeScript:
runs-on: macos-latest
steps:
- uses: actions/checkout@f095bcc56b7c2baf48f3ac70d6d6782f4f553222
- uses: cachix/install-nix-action@v15
- name: /tests/scriptWithHelp
run: nix-env -if . && m . /tests/scriptWithHelp
- name: /tests/makeScript
run: nix-env -if . && m . /tests/makeScript
env:
CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }}

Expand Down
2 changes: 1 addition & 1 deletion default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ let
projectPath = import ./src/args/project-path args;
projectSrc = ./.;
};
in import ./makes/main.nix args
in (import ./makes/makes.nix args).jobs."/"
7 changes: 1 addition & 6 deletions makes.nix
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
{ fetchNixpkgs, fetchUrl, makeScript, outputs, projectPath, __nixpkgs__, ...
}: {
jobs = {
"/test" = makeScript {
name = "test/job";
entrypoint = "echo Hello test";
};
};
imports = [ ./makes/makes.nix ];
projectIdentifier = "makes-repo";
cache = {
readNixos = true;
Expand Down
16 changes: 0 additions & 16 deletions makes/main.nix

This file was deleted.

29 changes: 29 additions & 0 deletions makes/makes.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{ __nixpkgs__, makeScript, outputs, projectPath, ... }:
let makesVersion = "24.12";
in {
imports = [
./tests/commitlint/makes.nix
./tests/computeOnAwsBatch/makes.nix
./tests/makeScript/makes.nix
./tests/makeSearchPaths/makes.nix
./tests/makeTemplate/makes.nix
./tests/secretsForGpgFromEnv/makes.nix
./utils/makePythonLock/makes.nix
./utils/makeRubyLock/makes.nix
];

jobs."/" = makeScript {
aliases = [ "m-v${makesVersion}" "makes" "makes-v${makesVersion}" ];
replace = {
__argMakesSrc__ = projectPath "/";
__argNix__ = __nixpkgs__.nixVersions.nix_2_15;
};
entrypoint = ''
__MAKES_SRC__=__argMakesSrc__ \
__NIX__=__argNix__ \
python -u __argMakesSrc__/src/cli/main/__main__.py "$@"
'';
searchPaths.source = [ outputs."/cli/env/runtime" ];
name = "m";
};
}
13 changes: 0 additions & 13 deletions makes/tests/commitlint/main.nix

This file was deleted.

14 changes: 14 additions & 0 deletions makes/tests/commitlint/makes.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{ makeScript, __nixpkgs__, ... }: {
jobs."/tests/commitlint" = makeScript {
name = "commitlint";
entrypoint = ''
pushd makes/tests/commitlint
commit_hash="$(git --no-pager log --pretty=%h origin/main..HEAD)"
info "Linting commit $commit_hash"
git log -1 --pretty=%B $commit_hash | commitlint --parser-preset ./parser.js --config ./config.js
'';
searchPaths.bin = [ __nixpkgs__.commitlint __nixpkgs__.git ];
};
}
20 changes: 0 additions & 20 deletions makes/tests/computeOnAwsBatch/main.nix

This file was deleted.

21 changes: 21 additions & 0 deletions makes/tests/computeOnAwsBatch/makes.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{ computeOnAwsBatch, ... }: {
jobs."/tests/computeOnAwsBatch" = computeOnAwsBatch {
dryRun = true;
allowDuplicates = true;
attempts = 1;
attemptDurationSeconds = 60;
command = [ "foo" ];
definition = "foo";
environment = [ ];
includePositionalArgsInName = true;
name = "foo";
nextJob = { };
memory = 1;
parallel = 1;
propagateTags = true;
queue = "foo";
setup = [ ];
tags = { };
vcpus = 1;
};
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# A Script With a Help

- This is `makes/tests/scriptWithHelp/README.md`
- This is `makes/tests/makeScript/README.md`
- You might be looking at it beautifully rendered on GitHub / GitLab / etc.
- You also might be looking at it beautifully rendedred on the CLI\*.

\* `m . /tests/scriptWithHelp -h` (or `--help`)
\* `m . /tests/makeScript -h` (or `--help`)
7 changes: 7 additions & 0 deletions makes/tests/makeScript/makes.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{ makeScript, ... }: {
jobs."/tests/makeScript" = makeScript {
entrypoint = "echo A script with a help, call with --help or -h to see it!";
name = "help";
help = ./README.md;
};
}
6 changes: 0 additions & 6 deletions makes/tests/makeSearchPaths/main.nix

This file was deleted.

7 changes: 7 additions & 0 deletions makes/tests/makeSearchPaths/makes.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{ makeDerivation, ... }: {
jobs."/tests/makeSearchPaths" = makeDerivation {
builder = "touch $out";
name = "test-make-search-paths";
searchPaths.source = [[ ./template.sh "a" "b" "c" ]];
};
}
13 changes: 0 additions & 13 deletions makes/tests/makeTemplate/main.nix

This file was deleted.

15 changes: 15 additions & 0 deletions makes/tests/makeTemplate/makes.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{ fromYaml, makeTemplate, ... }:
let
testFile = fromYaml (builtins.readFile ./test.yaml);
testString = testFile.testTitle;
in {
jobs."/tests/makeTemplate" = makeTemplate {
replace = {
__argFirst__ = "aaaaaaaaa";
__argSecond__ = "bbbb";
__argThird__ = testString;
};
name = "test-make-template";
template = ./template.txt;
};
}
6 changes: 0 additions & 6 deletions makes/tests/scriptWithHelp/main.nix

This file was deleted.

10 changes: 0 additions & 10 deletions makes/tests/secretsForGpgFromEnv/main.nix

This file was deleted.

11 changes: 11 additions & 0 deletions makes/tests/secretsForGpgFromEnv/makes.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{ makeScript, outputs, ... }: {
jobs."/tests/secretsForGpgFromEnv" = makeScript {
entrypoint = "echo $secret";
name = "tests-secrets-for-gpg-from-env";
searchPaths.source = [
outputs."/envVars/example"
outputs."/secretsForGpgFromEnv/example"
outputs."/secretsForEnvFromSops/example"
];
};
}
12 changes: 0 additions & 12 deletions makes/utils/makePythonLock/main.nix

This file was deleted.

13 changes: 13 additions & 0 deletions makes/utils/makePythonLock/makes.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{ __nixpkgs__, makeScript, ... }: {
jobs."/utils/makePythonLock" = makeScript {
entrypoint = ./entrypoint.sh;
name = "make-python-lock";
searchPaths.bin = [
__nixpkgs__.poetry
__nixpkgs__.python39
__nixpkgs__.python310
__nixpkgs__.python311
__nixpkgs__.python312
];
};
}
12 changes: 0 additions & 12 deletions makes/utils/makeRubyLock/main.nix

This file was deleted.

13 changes: 13 additions & 0 deletions makes/utils/makeRubyLock/makes.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{ __nixpkgs__, makeScript, ... }: {
jobs."/utils/makeRubyLock" = makeScript {
entrypoint = ./entrypoint.sh;
name = "make-ruby-lock";
replace = {
__argParser__ = ./parser.rb;
__argRuby31__ = __nixpkgs__.ruby_3_1;
__argRuby32__ = __nixpkgs__.ruby_3_2;
__argRuby33__ = __nixpkgs__.ruby_3_3;
};
searchPaths.bin = [ __nixpkgs__.nixVersions.nix_2_15 __nixpkgs__.yj ];
};
}

0 comments on commit f23013d

Please sign in to comment.