commit
95c9cfc24f
4 changed files with 56 additions and 17 deletions
17
ci/deploy.sh
17
ci/deploy.sh
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
set -eu -o pipefail # Exit with nonzero exit code if anything fails
|
||||
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
|
||||
|
||||
is-automatic-update() {
|
||||
[[ "$TRAVIS_EVENT_TYPE" == "cron" ]] || [[ "$TRAVIS_EVENT_TYPE" == "api" ]]
|
||||
}
|
||||
|
|
@ -26,25 +28,14 @@ export encrypted_080f214a372c_key= encrypted_080f214a372c_iv=
|
|||
|
||||
nix-build release.nix
|
||||
|
||||
result/bin/nur format-manifest
|
||||
if [ -n "$(git diff --exit-code repos.json)" ]; then
|
||||
echo "repos.json was not formatted before committing repos.json:" >&2
|
||||
git diff --exit-code repos.json
|
||||
echo "Please run ./bin/nur/format-manifest.py and updates repos.json accordingly!" >&2
|
||||
exit 1
|
||||
if ! is-automatic-update; then
|
||||
bash $DIR/lint.sh
|
||||
fi
|
||||
|
||||
result/bin/nur update
|
||||
nix-build
|
||||
|
||||
if ! is-automatic-update; then
|
||||
# Type checker
|
||||
nix run nixpkgs.python3Packages.mypy -c mypy nur
|
||||
# Format checker
|
||||
nix run nixpkgs.python3Packages.black -c black --check .
|
||||
# Linter
|
||||
nix run nixpkgs.python3Packages.flake8 -c flake8 .
|
||||
|
||||
# Pull requests and commits to other branches shouldn't try to deploy, just build to verify
|
||||
echo "Skipping deploy; just doing a build."
|
||||
exit 0
|
||||
|
|
|
|||
18
ci/lint.sh
Executable file
18
ci/lint.sh
Executable file
|
|
@ -0,0 +1,18 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -eu -o pipefail # Exit with nonzero exit code if anything fails
|
||||
|
||||
$(nix-build --no-out-link release.nix)/bin/nur format-manifest
|
||||
if [ -n "$(git diff --exit-code repos.json)" ]; then
|
||||
echo "repos.json was not formatted before committing repos.json:" >&2
|
||||
git diff --exit-code repos.json
|
||||
echo "Please run ./bin/nur/format-manifest.py and updates repos.json accordingly!" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Type checker
|
||||
nix run nixpkgs.python3Packages.mypy -c mypy nur
|
||||
# Format checker
|
||||
nix run nixpkgs.python3Packages.black -c black --check .
|
||||
# Linter
|
||||
nix run nixpkgs.python3Packages.flake8 -c flake8 .
|
||||
|
|
@ -85,6 +85,14 @@ def remove_repo(repo: Repo, path: Path) -> None:
|
|||
commit_files([str(repo_path)], f"{repo.name}: remove")
|
||||
|
||||
|
||||
def update_manifest(repos: List[Repo], path: Path) -> None:
|
||||
d = {}
|
||||
|
||||
for repo in repos:
|
||||
d[repo.name] = repo.as_json()
|
||||
write_json_file(dict(repos=d), path)
|
||||
|
||||
|
||||
def update_channel(path: Path) -> None:
|
||||
manifest = load_manifest(MANIFEST_PATH, LOCK_PATH)
|
||||
|
||||
|
|
@ -112,6 +120,8 @@ def update_channel(path: Path) -> None:
|
|||
for channel_repo in channel_repos.values():
|
||||
remove_repo(channel_repo, path)
|
||||
|
||||
update_manifest(updated_repos, path.joinpath("repos.json"))
|
||||
|
||||
update_lock_file(updated_repos, path.joinpath("repos.json.lock"))
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ class RepoType(Enum):
|
|||
GIT = auto()
|
||||
|
||||
@staticmethod
|
||||
def from_repo(repo: "Repo", type_: str) -> "RepoType":
|
||||
def from_repo(repo: "Repo", type_: Optional[str]) -> "RepoType":
|
||||
if repo.submodules:
|
||||
return RepoType.GIT
|
||||
if repo.url.hostname == "github.com":
|
||||
|
|
@ -55,7 +55,7 @@ class Repo:
|
|||
name: str,
|
||||
url: Url,
|
||||
submodules: bool,
|
||||
type_: str,
|
||||
supplied_type: Optional[str],
|
||||
file_: Optional[str],
|
||||
locked_version: Optional[LockedVersion],
|
||||
) -> None:
|
||||
|
|
@ -75,11 +75,30 @@ class Repo:
|
|||
):
|
||||
self.locked_version = locked_version
|
||||
|
||||
self.type = RepoType.from_repo(self, type_)
|
||||
self.supplied_type = supplied_type
|
||||
self.computed_type = RepoType.from_repo(self, supplied_type)
|
||||
|
||||
@property
|
||||
def type(self) -> RepoType:
|
||||
return self.computed_type
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"<{self.__class__.__name__} {self.name}>"
|
||||
|
||||
def as_json(self) -> Dict[str, Any]:
|
||||
d = dict(url=self.url.geturl()) # type: Dict[str, Any]
|
||||
|
||||
if self.submodules:
|
||||
d["submodules"] = self.submodules
|
||||
|
||||
if self.supplied_type is not None:
|
||||
d["type"] = self.supplied_type
|
||||
|
||||
if self.file is not None and self.file != "default.nix":
|
||||
d["file"] = self.file
|
||||
|
||||
return d
|
||||
|
||||
|
||||
class Manifest:
|
||||
def __init__(self, repos: List[Repo]) -> None:
|
||||
|
|
@ -99,7 +118,8 @@ def _load_locked_versions(path: PathType) -> Dict[str, LockedVersion]:
|
|||
url = urlparse(repo["url"])
|
||||
rev = repo["rev"]
|
||||
sha256 = repo["sha256"]
|
||||
locked_versions[name] = LockedVersion(url, rev, sha256)
|
||||
submodules = repo.get("submodules", False)
|
||||
locked_versions[name] = LockedVersion(url, rev, sha256, submodules)
|
||||
|
||||
return locked_versions
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue