Skip to content

Commit

Permalink
testing
Browse files Browse the repository at this point in the history
  • Loading branch information
leona-ya committed Dec 18, 2024
1 parent 7e62860 commit f17a42c
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 17 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/update-nixpkgs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
git config --global user.email '${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com>'
- uses: actions/checkout@v4
with:
repository: flyingcircusio/fc-nixos
repository: flyingcircusio/fc-nixos-testing
path: 'fc-nixos'
token: ${{ steps.app-token.outputs.token }}
# fetch all branches and tags
Expand All @@ -47,7 +47,8 @@ jobs:
--fc-nixos-dir fc-nixos \
--nixpkgs-dir nixpkgs \
--nixpkgs-upstream-url https://github.com/NixOS/nixpkgs \
--nixpkgs-origin-url https://x-access-token:${{steps.app-token.outputs.token}}@github.com/flyingcircusio/nixpkgs.git \
--nixpkgs-origin-url https://x-access-token:${{steps.app-token.outputs.token}}@github.com/flyingcircusio/nixpkgs-testing.git \
--platform-versions 24.05 ${{ github.event_name == 'workflow_dispatch' && '--force' || '' }}
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
MATRIX_HOOKSHOT_URL: ${{ secrets.MATRIX_HOOKSHOT_URL }}
4 changes: 2 additions & 2 deletions src/update_nixpkgs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import sys
from logging import INFO, basicConfig

FC_NIXOS_REPO = "flyingcircusio/fc-nixos"
NIXPKGS_REPO = "flyingcircusio/nixpkgs"
FC_NIXOS_REPO = "flyingcircusio/fc-nixos-testing"
NIXPKGS_REPO = "flyingcircusio/nixpkgs-testing"


def main():
Expand Down
22 changes: 11 additions & 11 deletions src/update_nixpkgs/cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,31 +51,31 @@ def nixpkgs_repository(directory: str, remotes: dict[str, Remote]) -> Repo:
return repo


def check_nixpkgs_up_to_date(nixpkgs_repo: Repo, fc_nixos_dir: str, target_branch: str, integration_branch: str, fc_nixos_pr: PullRequest, matrix_hookshot: MatrixHookshot):
def check_nixpkgs_up_to_date(nixpkgs_repo: Repo, fc_nixos_dir: str, fc_nixos_target_branch: str, nixpkgs_target_branch: str, integration_branch: str, fc_nixos_pr: PullRequest, matrix_hookshot: MatrixHookshot):
fc_nixos_repo = Repo(fc_nixos_dir)
versions_json_path = Path(fc_nixos_dir) / "release" / "versions.json"

merge_base = fc_nixos_repo.merge_base(
f"origin/{target_branch}", f"origin/{integration_branch}"
)
# HEAD = the head of the merged PR (before merge)
# XXX: This makes an assumption that the PR only contains 1 commit. This should be cleaned up.
merge_base = fc_nixos_repo.git.rev_parse("HEAD^")
# The integration branch is directly branched of the target branch, so we can only have one merge base.
assert len(merge_base) == 1
fc_nixos_repo.git.switch(merge_base[0].hexsha, detach=True)
fc_nixos_repo.git.switch(merge_base, detach=True)

with open(versions_json_path) as f:
versions = json.load(f)
previous_versions_rev = versions["nixpkgs"]["rev"]

current_fc_nixos_commit = nixpkgs_repo.refs[f"origin/{target_branch}"].commit
current_fc_nixos_commit = nixpkgs_repo.refs[f"origin/{nixpkgs_target_branch}"].commit
result = current_fc_nixos_commit.hexsha == previous_versions_rev
if not result:
notification = f"""ERROR Unable to promote nixpkgs daily integration branch `{integration_branch}` to `{target_branch}`.
Integration branch not up to date. Expected commit `{previous_versions_rev}` as HEAD commit of `flyingcircusio/nixpkgs/{target_branch}`, but got `{current_fc_nixos_commit.hexsha}`.
notification = f"""ERROR Unable to promote nixpkgs daily integration branch `{integration_branch}` to `{nixpkgs_target_branch}`.
Integration branch not up to date. Expected commit `{previous_versions_rev}` as HEAD commit of `flyingcircusio/nixpkgs/{nixpkgs_target_branch}`, but got `{current_fc_nixos_commit.hexsha}`.
Please resolve manually by looking at the changes in nixpkgs between these commits, and then run the update-script for fc-nixos."""
fc_nixos_pr.create_issue_comment(notification)
matrix_hookshot.send_notification(f"update-nixpkgs PR #{fc_nixos_pr.number}: {notification}")

logging.info(f"Expected commit `{previous_versions_rev}` as HEAD commit of `flyingcircusio/nixpkgs/{nixpkgs_target_branch}`, but got `{current_fc_nixos_commit.hexsha}`")
return result

def promote_nixpkgs(
gh: Github, nixpkgs_repo: Repo, target_branch: str, integration_branch: str
Expand Down Expand Up @@ -146,7 +146,7 @@ def run(
}

nixpkgs_repo = nixpkgs_repository(nixpkgs_dir, remotes)
if not check_nixpkgs_up_to_date(nixpkgs_repo, fc_nixos_dir, nixpkgs_target_branch, integration_branch, fc_nixos_pr, matrix_hookshot):
if not check_nixpkgs_up_to_date(nixpkgs_repo, fc_nixos_dir, fc_nixos_pr.base.ref, nixpkgs_target_branch, integration_branch, fc_nixos_pr, matrix_hookshot):
logging.error("Abort promotion of nixpkgs branch. PR is not up to date.")
return
if promote_nixpkgs(gh, nixpkgs_repo, nixpkgs_target_branch, integration_branch):
Expand Down
3 changes: 2 additions & 1 deletion src/update_nixpkgs/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,8 @@ def run(
nixpkgs_target_branch,
integration_branch,
last_day_integration_branch,
force
force,
matrix_hookshot
):
logging.info(
f"Updated 'nixpkgs' to '{result.fork_after_rebase.hexsha}'"
Expand Down
2 changes: 1 addition & 1 deletion src/utils/matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ def __init__(self, hookshot_url):
def send_notification(self, message: str):
requests.put(self.hookshot_url, json={
"text": message
})
}).raise_for_status()

0 comments on commit f17a42c

Please sign in to comment.