-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
115 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
name: CI | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
generate-matrix: | ||
name: Generate job matrices | ||
runs-on: ubuntu-latest | ||
outputs: | ||
darwin-configurations: ${{ steps.x.outputs.matrix }} | ||
darwin-modules: ${{ steps.x.outputs.matrix }} | ||
home-configurations: ${{ steps.x.outputs.matrix }} | ||
home-modules: ${{ steps.x.outputs.matrix }} | ||
nixos-configurations: ${{ steps.x.outputs.matrix }} | ||
nixos-modules: ${{ steps.x.outputs.matrix }} | ||
nixos-tests: ${{ steps.x.outputs.matrix }} | ||
steps: | ||
- name: Get changes | ||
id: changed-files | ||
uses: tj-actions/changed-files@v44 | ||
with: | ||
dir_names_max_depth: 1 | ||
dir_names: true | ||
matrix: true | ||
|
||
# nix | ||
|
||
# - name: Generate matrix | Infrastructure | ||
# id: neo-infrastructure | ||
# uses: hellofresh/action-changed-files@v3 | ||
# with: | ||
# pattern: infrastructure/(?P<environment>[^/]+) | ||
# default-patterns: | | ||
# terraform-modules | ||
# deploy.sh | ||
|
||
# - name: Generate matrix | Library | ||
# id: neo-library | ||
# uses: hellofresh/action-changed-files@v3 | ||
# with: | ||
# pattern: library/(?P<lib>(?!common)[^/]+) | ||
# default-patterns: | | ||
# library/common | ||
|
||
# infrastructure: | ||
# runs-on: ubuntu-latest | ||
# needs: [ generate-matrix ] # don't forget this! | ||
# strategy: | ||
# matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix-infrastructure) }} | ||
# if: ${{ fromJson(needs.generate-matrix.outputs.matrix-infrastructure).include[0] }} # skip if the matrix is empty! | ||
# steps: | ||
# - name: Deploy infrastructure | ||
# run: echo "Deploying ${{ matrix.environment }}" | ||
|
||
# build: | ||
# runs-on: ubuntu-latest | ||
# needs: [ generate-matrix ] | ||
# strategy: | ||
# matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix-build) }} | ||
# if: ${{ fromJson(needs.generate-matrix.outputs.matrix-build).include[0] }} | ||
# steps: | ||
# - name: Building library | ||
# run: echo "Building ${{ matrix.lib }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import os | ||
import re | ||
|
||
import networkx as nx | ||
|
||
moduleSystems = ["darwin", "home", "nixos"] | ||
moduleTypes = ["configurations", "modules", "tests"] | ||
ezModulePattern = re.compile(r"ezModules.([a-zA-Z-1-9]+)") | ||
inputsModulePattern = re.compile(r"[^-]inputs.([a-zA-Z-1-9]+)") | ||
|
||
G = nx.Graph() | ||
|
||
for ms in moduleSystems: | ||
for mt in moduleTypes: | ||
folder = f"{ms}-{mt}" | ||
|
||
if os.path.exists(folder): | ||
for fd in os.scandir(folder): | ||
module = folder + "/" + fd.name.removesuffix(".nix") | ||
|
||
if mt == "configurations": | ||
defaultModule = f"{ms}-modules/default" | ||
G.add_edge(module, defaultModule) | ||
|
||
if fd.name.endswith(".nix"): | ||
with open(fd, encoding="utf-8") as f: | ||
data = f.read() | ||
for match in re.finditer(ezModulePattern, data): | ||
dep = f"{ms}-modules/{match.group(1)}" | ||
G.add_edge(module, dep) | ||
|
||
for match in re.finditer(inputsModulePattern, data): | ||
dep = f"inputs/{match.group(1)}" | ||
G.add_edge(module, dep) | ||
else: | ||
for sub_fd in os.scandir(fd.path): | ||
with open(sub_fd, encoding="utf-8") as f: | ||
data = f.read() | ||
for match in re.finditer(ezModulePattern, data): | ||
dep = f"{ms}-modules/{match.group(1)}" | ||
G.add_edge(module, dep) | ||
|
||
print(G.nodes) | ||
print(nx.shortest_path(G, "darwin-configurations/Fox", "inputs/nixpkgs-unstable")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters