Skip to content
Closed
21 changes: 15 additions & 6 deletions .github/workflows/pr_test.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
name: pr_test
description: Check Pull Request

on:
workflow_dispatch:
pull_request:

jobs:

dummy:
version-update:
runs-on: ubuntu-22.04
steps:
- name: Do nothing yet
shell: bash
run: |
echo "ToDo"

- name: Check wether the versions.md file have been updated
uses: eProsima/eProsima-CI/ubuntu/check_version_update@feature/markdown-linter

markdown-linter:
runs-on: ubuntu-22.04
steps:

- name: Linter all markdown files
uses: eProsima/eProsima-CI/ubuntu/markdown_linter@feature/markdown-linter
with:
# TODO modify this when PR is merged
linter_configuration_version: feature/markdown-linter
# linter_configuration_version: master
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ The main idea is to collect every repeated or generic step of any CI to have a s
- [User manual](#user-manual)
- [Out-of-the-box Actions Implemented](#out-of-the-box-actions-implemented)
- [Actions Implemented](#actions-implemented)
- [Multiplatform](#multiplatform)
- [Ubuntu](#ubuntu)
- [Dependencies built](#dependencies-built)
- [Artifacts uploaded](#artifacts-uploaded)
- [Multiplatform](#multiplatform)
- [Ubuntu](#ubuntu)
- [Workflows](#workflows)
- [Artifacts uploaded](#artifacts-uploaded)
- [Generate artifacts manually](#generate-artifacts-manually)
- [Custom artifact generation](#custom-artifact-generation)
- [External Actions](#external-actions)

---
Expand Down Expand Up @@ -49,6 +50,10 @@ For more information about versioning handle of this project, check following [f
- *Only on ubuntu*.
- *Only for documentation projects based in [cmake_utils](https://github.com/eProsima/dev-utils)*.

- [check_version_update](ubuntu/check_version_update/action.yml)
- Check that the document containing version changes have changed.
- *Only on ubuntu*.

---

## Actions Implemented
Expand Down Expand Up @@ -124,6 +129,10 @@ For more information about versioning handle of this project, check following [f
- Get the files that differ from one github reference to another.
The result can be parsed with `grep`.

- [git_diff](ubuntu/git_diff/action.yml)
- Get the diff file of a file contained in a git repository.
It returns true or false whether the file has changes.

- [git_fetch_all](ubuntu/git_fetch_all/action.yml)
- Get all branches of a specific repository.

Expand Down
5 changes: 5 additions & 0 deletions external/create-pull-request/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,24 @@ outputs:

pull-request-number:
description: 'The pull request number'
pull-request-number: ${{ steps.run.outputs.pull-request-number }}
pull-request-url:
description: 'The URL of the pull request.'
pull-request-url: ${{ steps.run.outputs.pull-request-url }}
pull-request-operation:
description: 'The pull request operation performed by the action, `created`, `updated` or `closed`.'
pull-request-operation: ${{ steps.run.outputs.pull-request-operation }}
pull-request-head-sha:
description: 'The commit SHA of the pull request branch.'
pull-request-head-sha: ${{ steps.run.outputs.pull-request-head-sha }}

runs:
using: composite
steps:

- name: Create PR
uses: peter-evans/create-pull-request@v5
id: run
with:
token: ${{ inputs.token }}
path: ${{ inputs.path }}
Expand Down
52 changes: 52 additions & 0 deletions ubuntu/check_version_update/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: check_version_update
description: Check if version file has been updated with the change in the repository

inputs:

version-file-path:
description: The path to the file to check for changes from repository base
required: true
default: versions.md

head-ref:
description: Git reference to compare file
required: false
default: ${GITHUB_HEAD_REF}

base-ref:
description: Git reference to compare against
required: false
default: ${GITHUB_BASE_REF}

runs:
using: composite
steps:

- name: Sync repository
uses: eProsima/eProsima-CI/external/checkout@feature/markdown-linter
with:
path: ${{ github.workspace }}

- name: Fetch all branches and tags
uses: eProsima/eProsima-CI/ubuntu/git_fetch_all@feature/markdown-linter
with:
workspace: ${{ github.workspace }}

- name: Get diff file of version file
id: git-diff
uses: eProsima/eProsima-CI/ubuntu/git_diff@feature/markdown-linter
with:
file-path: ${{ github.workspace }}/${{ inputs.version-file-path }}

- name: Check if file change
shell: bash
run: |

if [[ "${{ steps.git-diff.outputs.have-changes }}" != "true" ]]; then
echo "Version file ${{ inputs.version-file-path }} has not been updated"
echo "T.T"
exit 1
else
echo "Version file ${{ inputs.version-file-path }} updated."
echo "HURRAY! ^.^"
fi
64 changes: 64 additions & 0 deletions ubuntu/git_diff/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: git_diff
description: Check whether a file in a repository has changed and return diff file

inputs:

file-path:
description: The path to the file to check for changes
required: true

head-ref:
description: Git reference to compare file
required: false
default: origin/${GITHUB_HEAD_REF}

base-ref:
description: Git reference to compare against
required: false
default: origin/${GITHUB_BASE_REF}

diff-args:
description: Additional arguments to pass to the git diff command
required: false
default: ''

result-file:
description: Additional arguments to pass to the git diff command
required: false
default: ${{ github.workspace }}/git.diff

outputs:

have-changes:
description: Whether there have been changes in such file
value: ${{ steps.run.outputs.have-changes }}

runs:
using: composite
steps:

- name: get_git_diff_files
id: run
shell: bash
run: |

echo "::group::Get git modifications of file ${{ inputs.file-path }}"

git diff "${{ inputs.base-ref }}" "${{ inputs.head-ref }}" ${{ inputs.diff-args }} -- "${{ inputs.file-path }}" > "${{ inputs.result-file }}"

echo "Diff file result:"
cat "${{ inputs.result-file }}"

if [ -s "${{ inputs.result-file }}" ]; then

echo "have-changes=true" >> $GITHUB_OUTPUT
echo "File has changes"

else

echo "have-changes=false" >> $GITHUB_OUTPUT
echo "File has not changes"

fi

echo "::endgroup::"
16 changes: 16 additions & 0 deletions ubuntu/install_markdownlint/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: install_markdownlint

runs:
using: composite
steps:

- name: install_markdownlint
run: |

echo "::group::Install Markdown packages"

sudo gem install mdl

echo "::endgroup::"

shell: bash
115 changes: 115 additions & 0 deletions ubuntu/markdown_linter/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# Execute makrdownlint MarkDown linter job from the same repo that calls this action.
#
# Runs on:
# - Ubuntu 20.04
# - Ubuntu 22.04
#
# Steps:
# - Checkout repository and fetch unshallow to be able to compare
# - Install packages required
# - Get the file names of those files that has changed between base and head branch
# - Execute markdownlint over those files (only .md and README ones).
#
# Arguments:
# - linter_configuration_version : branch of cpp-style repo to get configuration from [master]
# - file_grep_args : grep filer for file extensions [-e '\\.md' -e 'README']
# - markdownlint_args : arguments for markdownlint []

name: markdown_linter
description: MarkDown Linter action to check Python modified files.

inputs:

linter_configuration_version:
description: Branch of eProsima/cpp-style
required: false
default: master

file_grep_args:
description: Extensions of the files to check as markdown, as grep filter arguments
required: false
default: "-e '\\.md' -e 'README'"

markdownlint_args:
description: Arguments for markdownlint
required: false
default: ''

runs:
using: composite
steps:

- name: Sync repository
uses: eProsima/eProsima-CI/external/checkout@feature/markdown-linter
with:
path: src

- name: Fetch all branches and tags
uses: eProsima/eProsima-CI/ubuntu/git_fetch_all@feature/markdown-linter
with:
workspace: src

- name: Install markdownlint
uses: eProsima/eProsima-CI/ubuntu/install_markdownlint@feature/markdown-linter

- name: Fetch markdown linter config file
uses: eProsima/eProsima-CI/ubuntu/get_file_from_repo@feature/markdown-linter
with:
source_repository_branch: ${{ inputs.linter_configuration_version }}
source_repository: eProsima/cpp-style
file_name: markdownlint_linter.rb
file_result: markdownlint_linter.rb

- name: Get Git difference
id: GetGitDifference
uses: eProsima/eProsima-CI/ubuntu/get_git_diff_files@feature/markdown-linter
with:
result_env_var:
MODIFIED_FILES
head_ref:
origin/${GITHUB_HEAD_REF}
base_ref:
origin/${GITHUB_BASE_REF}
grep_args:
${{ inputs.file_grep_args }}
workspace:
src

- name: Check difference is not empty
run: |
cd src
if [[ -z "${MODIFIED_FILES}" ]]
then
touch __empty.md
echo "MODIFIED_FILES=__empty.md" >> $GITHUB_ENV
fi
echo "Files to check: ${MODIFIED_FILES}"
shell: bash

# TODO remove
# This file is required due to a bug in markdownlint that do not allow to use a config file
- name: Add config path file
run: |
cd src
echo "style '../markdownlint_linter.rb'" > .mdlrc
ls
cat .mdlrc
cat ../markdownlint_linter.rb
shell: bash

- name: Check style
run: |
cd src

echo "################################################################################################"
echo "################################### MARKDOWN LINTER RESULTS ####################################"

mdl ${{ inputs.markdownlint_args }} ${MODIFIED_FILES}

# When bug is fixed, uncomment this
# mdl --config ../markdownlint_linter.rb ${{ inputs.markdownlint_args }} ${MODIFIED_FILES}

echo "############################### MARKDOWN LINTER CHECK SUCCESSFUL ###############################"
echo "################################################################################################"

shell: bash
10 changes: 10 additions & 0 deletions versions.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ The *Forthcoming* section includes those features added in `main` branch that ar
- [v0.3.0](#v0.3.0)
- [v0.2.0](#v0.2.0)

## Forthcoming

This release includes the following **CI features**:

- Add a check for every PR that checks if `versions.md` file have been updated with new PRs.

This release includes the following **features**:

- `check_version_update` action to check if version documentation file have been updated.

## v0.3.0

This release includes the following **bug-fixes**:
Expand Down