Initial spec lint action commit (#172) (#190)

* Initial spec-cleaner commit for CBL-Mariner

* Add cgmanifest.json file for GitHub workflows folder

* Set continue-on-error to true for a trial period
This commit is contained in:
Thomas Crain 2020-10-19 15:28:53 -07:00 коммит произвёл GitHub
Родитель aa98edb3ac
Коммит 20d96891ba
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 21870 добавлений и 0 удалений

14
.github/workflows/cgmanifest.json поставляемый Normal file
Просмотреть файл

@ -0,0 +1,14 @@
{
"Registrations": [
{
"Component": {
"Type": "git",
"Git": {
"RepositoryUrl": "https://github.com/rpm-software-management/spec-cleaner",
"CommitHash": "f24cd83e5e2775b061696d4fd7fcf47f63514b50"
}
}
}
],
"Version": 1
}

95
.github/workflows/lint-specs.yml поставляемый Normal file
Просмотреть файл

@ -0,0 +1,95 @@
name: Spec Linting
on:
push:
paths:
- '**.spec'
branches: [main, dev, 1.0*]
pull_request:
paths:
- '**.spec'
branches: [main, dev, 1.0*]
jobs:
spec-lint:
runs-on: ubuntu-latest
steps:
# Checkout the branch of our repo that triggered this action
- name: Workflow trigger checkout
uses: actions/checkout@v2
- name: Get base commit for PRs
if: ${{ github.event_name == 'pull_request' }}
run: |
git fetch origin ${{ github.base_ref }}
echo "base_sha=$(git rev-parse origin/${{ github.base_ref }})" >> $GITHUB_ENV
echo "Merging ${{ github.sha }} into ${{ github.base_ref }}"
- name: Get base commit for Pushes
if: ${{ github.event_name == 'push' }}
run: |
git fetch origin ${{ github.event.before }}
echo "base_sha=${{ github.event.before }}" >> $GITHUB_ENV
echo "Merging ${{ github.sha }} into ${{ github.event.before }}"
- name: Get the changed files
run: |
echo "Files changed: '$(git diff-tree --no-commit-id --name-only -r ${{ env.base_sha }} ${{ github.sha }})'"
changed_specs=$(git diff-tree --no-commit-id --name-only -r ${{ env.base_sha }} ${{ github.sha }} | { grep "\.spec$" || test $? = 1; })
echo "Files to validate: '${changed_specs}'"
echo "updated-specs=$(echo ${changed_specs})" >> $GITHUB_ENV
- name: Main branch checkout
uses: actions/checkout@v2
with:
ref: 'main'
path: 'main-checkout'
# Our linter is based on the spec-cleaner tool from the folks at openSUSE
# We apply a patch to modify it for CBL-Mariner's needs
- name: spec-cleaner checkout
uses: actions/checkout@v2
with:
repository: 'rpm-software-management/spec-cleaner'
ref: 'spec-cleaner-1.2.0'
path: 'spec-cleaner'
# For consistency, we use the same major/minor version of Python that CBL-Mariner ships
- name: Setup Python 3.7
uses: actions/setup-python@v2
with:
python-version: 3.7
# We take our version of the linting tool from the master branch to ensure rules
# are consistent across all branches
- name: Patch spec-cleaner with Mariner-specific lints
run: |
pushd spec-cleaner
git apply ../main-checkout/.github/workflows/mariner-spec-cleaner.patch
popd
- name: Install patched spec-cleaner
run: |
python -m pip install --upgrade pip
pip install -e ./spec-cleaner
# Set continue-on-error to true if we're blocking too many PRs here
# We don't want this tool to have a low signal-to-noise ratio
- name: Lint changed spec files
continue-on-error: true
run: |
mkdir -p linted_specs
spec-cleaner -o linted_specs ${{ env.updated-specs }}
[ -n "$(ls -A linted_specs)" ] \
&& echo "Specs are not correctly formatted." \
&& echo "The linted_specs artifact contains linted versions of the specs you're checking in." \
&& echo "Please properly format your specs according to that output before merging." \
&& exit 1
- uses: actions/upload-artifact@v2
with:
name: linted_specs
path: linted_specs
if-no-files-found: ignore
if: always()

21761
.github/workflows/mariner-spec-cleaner.patch поставляемый Executable file

Различия файлов скрыты, потому что одна или несколько строк слишком длинны