Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP]: new-plugin CI workflow #2255

Draft
wants to merge 22 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 115 additions & 0 deletions .github/workflows/new-plugin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: new-plugin
on:
push:
branches:
- "main"
paths:
- "plugins/**"

# Prevent running this workflow concurrently
concurrency:
group: "matrix-messages"

jobs:
setup:
name: Collect metadata and setup job matrix
runs-on: ubuntu-latest
timeout-minutes: 40
if: github.repository == 'nix-community/nixvim'
outputs:
json: ${{ steps.get_info.outputs.json }}

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Nix
uses: cachix/install-nix-action@v26
with:
nix_path: nixpkgs=channel:nixos-unstable
github_access_token: ${{ secrets.GITHUB_TOKEN }}

- name: Get plugins info
id: get_info
run: |
# Run the `plugin-info` tool, printing the result to write to GITHUB_OUTPUT
echo "json=$(
nix run .#plugin-info -- \
-c \
'github:${{ github.repository }}/${{ github.event.before }}'
)" >> $GITHUB_OUTPUT

send:
name: Send matrix message
runs-on: ubuntu-latest
needs: setup
if: ${{ fromJSON(needs.setup.outputs.json).removed == [] && fromJSON(needs.setup.outputs.json).added != [] }}
strategy:
matrix:
added: ${{ fromJSON(needs.setup.outputs.json).added }}
env:
name: ${{ matrix.added.name }}
plain: ${{ matrix.added.plain }}
html: ${{ matrix.added.html }}
markdown: ${{ matrix.added.markdown }}

steps:
- name: Install matrix-msg tool
uses: lkiesow/matrix-notification@v1
with:
token: ${{ secrets.CI_MATRIX_TOKEN }}
server: ${{ secrets.CI_MATRIX_SERVER }}
room: ${{ secrets.CI_MATRIX_ROOM }}
tool: true

- name: Send message and print summary
run: |
# stdout
echo "$plain"

# markdown summary
echo "$markdown" >> $GITHUG_STEP_SUMMARY
echo -e "\n---\n" >> $GITHUG_STEP_SUMMARY

# matrix message
if matrix-msg "$plain" "$html"
then
echo "Matrix message sent successfully" >> $GITHUG_STEP_SUMMARY
else
echo "Matrix message failed" >> $GITHUG_STEP_SUMMARY
fi

report:
name: Report removed plugins
runs-on: ubuntu-latest
needs: setup
if: ${{ fromJSON(needs.setup.outputs.json).removed != [] }}
env:
json: ${{ needs.setup.outputs.json }}

steps:
- name: Comment on PR
if: ${{ fromJSON(needs.setup.outputs.json).pr }}
env:
GH_TOKEN: ${{ github.token }}
num: ${{ fromJSON(needs.setup.outputs.json).pr.number }}
run: |
body="
> [!WARNING]
> Not posting announcements to Matrix because plugins were removed in this PR.
> Please post announcements manually.

Added:
$(echo "$json" | jq -r '.added[] | "- \(.name)"')

Removed:
$(echo "$json" | jq -r '.removed[] | "- \(.)"')
"

# Markdown summary
echo "$body" >> $GITHUG_STEP_SUMMARY

# PR comment
gh pr comment "$num" \
--repo '${{ github.repository }}' \
--body "$body"
6 changes: 3 additions & 3 deletions docs/mdbook/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ let
maintToMD = m: if m ? github then "[${m.name}](https://github.com/${m.github})" else m.name;
in
# Make sure this path has a valid info attrset
if info ? file && info ? description && info ? url then
if info._type or null == "nixvimInfo" then
"# ${lib.last path}\n\n"
+ (lib.optionalString (info.url != null) "**URL:** [${info.url}](${info.url})\n\n")
+ (lib.optionalString (info.url or null != null) "**URL:** [${info.url}](${info.url})\n\n")
+ (lib.optionalString (
maintainers != [ ]
) "**Maintainers:** ${lib.concatStringsSep ", " maintainersNames}\n\n")
+ lib.optionalString (info.description != null) ''
+ lib.optionalString (info.description or null != null) ''

---

Expand Down
15 changes: 15 additions & 0 deletions flake-modules/dev/ci-new-plugin-matrix.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
perSystem =
{ pkgs, ... }:
{
apps.ci-new-plugin-matrix.program = pkgs.writers.writePython3Bin "test_python3" {
libraries = with pkgs.python3Packages; [
requests
];
flakeIgnore = [
"E501" # Line length
"W503" # Line break before binary operator
];
} (builtins.readFile ./ci-new-plugin-matrix.py);
};
}
Loading