Skip to content

Commit

Permalink
prettier check (#68)
Browse files Browse the repository at this point in the history
* prettier check

* add automatic formatting updates

* make script executable

* exclude workflow files

* Automated formatting of files (#69)

Co-authored-by: Philip Top <top1@llnl.gov>
Co-authored-by: HELICS-bot <HELICS-bot@users.noreply.github.com>

* update the markdownlintrc

* add dockerfile linter

* update config location

* update create-file-docker image

* remove markdown from codacy

* fix codacy

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: HELICS-bot <HELICS-bot@users.noreply.github.com>
  • Loading branch information
3 people authored May 9, 2020
1 parent e43cb5a commit 5a329cd
Show file tree
Hide file tree
Showing 29 changed files with 969 additions and 612 deletions.
20 changes: 9 additions & 11 deletions .ci/azure-build.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
steps:
- task: CMake@1
inputs:
cmakeArgs: .. -DCMAKE_CXX_STANDARD=$(units.std) -DUNITS_HEADER_ONLY=$(units.header) -DCMAKE_BUILD_TYPE=$(units.build_type) $(units.options)
displayName: 'Configure'
env:
GIT_SSL_NO_VERIFY: 1

- task: CMake@1
inputs:
cmakeArgs: .. -DCMAKE_CXX_STANDARD=$(units.std) -DUNITS_HEADER_ONLY=$(units.header) -DCMAKE_BUILD_TYPE=$(units.build_type) $(units.options)
displayName: 'Configure'
env:
GIT_SSL_NO_VERIFY: 1

- script: cmake --build .
displayName: 'Build'
workingDirectory: build

- script: cmake --build .
displayName: 'Build'
workingDirectory: build
25 changes: 12 additions & 13 deletions .ci/azure-cmake.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
steps:
# Note that silkeh/clang does not include ca-certificates, so check the shasum for verification
- bash: |
wget --no-check-certificate "https://cmake.org/files/v3.14/cmake-3.14.3-Linux-x86_64.tar.gz"
echo "29faa62fb3a0b6323caa3d9557e1a5f1205614c0d4c5c2a9917f16a74f7eff68 cmake-3.14.3-Linux-x86_64.tar.gz" | shasum -sca 256
displayName: Download CMake
# Note that silkeh/clang does not include ca-certificates, so check the shasum for verification
- bash: |
wget --no-check-certificate "https://cmake.org/files/v3.14/cmake-3.14.3-Linux-x86_64.tar.gz"
echo "29faa62fb3a0b6323caa3d9557e1a5f1205614c0d4c5c2a9917f16a74f7eff68 cmake-3.14.3-Linux-x86_64.tar.gz" | shasum -sca 256
displayName: Download CMake
- task: ExtractFiles@1
inputs:
archiveFilePatterns: 'cmake*.tar.gz'
destinationFolder: 'cmake_program'
displayName: Extract CMake

- task: ExtractFiles@1
inputs:
archiveFilePatterns: 'cmake*.tar.gz'
destinationFolder: 'cmake_program'
displayName: Extract CMake

- bash: echo "##vso[task.prependpath]$(Build.SourcesDirectory)/cmake_program/cmake-3.14.3-Linux-x86_64/bin"
displayName: Add CMake to PATH
- bash: echo "##vso[task.prependpath]$(Build.SourcesDirectory)/cmake_program/cmake-3.14.3-Linux-x86_64/bin"
displayName: Add CMake to PATH
27 changes: 13 additions & 14 deletions .ci/azure-steps.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
steps:
- checkout: self
fetchDepth: 50
submodules: true

- checkout: self
fetchDepth: 50
submodules: true
- task: CMake@1
inputs:
cmakeArgs: .. -DCMAKE_BUILD_TYPE=Debug
displayName: 'Configure'

- task: CMake@1
inputs:
cmakeArgs: .. -DCMAKE_BUILD_TYPE=Debug
displayName: 'Configure'
- script: cmake --build . -j
displayName: 'Build'
workingDirectory: build

- script: cmake --build . -j
displayName: 'Build'
workingDirectory: build

- script: ctest --output-on-failure -C Debug
displayName: 'Test'
workingDirectory: build
- script: ctest --output-on-failure -C Debug
displayName: 'Test'
workingDirectory: build
19 changes: 8 additions & 11 deletions .ci/azure-test.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
steps:

- script: ctest --output-on-failure -C $(units.build_type) -T test
displayName: 'Test'
workingDirectory: build

- task: PublishTestResults@2
inputs:
testResultsFormat: 'cTest'
testResultsFiles: '**/Test.xml'


- script: ctest --output-on-failure -C $(units.build_type) -T test
displayName: 'Test'
workingDirectory: build

- task: PublishTestResults@2
inputs:
testResultsFormat: 'cTest'
testResultsFiles: '**/Test.xml'
4 changes: 0 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
version: 2
aliases:

- &run_units
name: run_units
environment:
Expand All @@ -22,7 +21,6 @@ aliases:
make QUICK_RAW_FUZZ
jobs:

unitsTSan:
docker:
- image: helics/buildenv:sanitizers
Expand Down Expand Up @@ -79,5 +77,3 @@ workflows:
- unitsASan
- unitsTSan
- unitsFuzz


4 changes: 2 additions & 2 deletions .cmake-format.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
"enum_char": ".",
"bullet_char": "*",
"line_ending": "unix",
"first_comment_is_literal":true,
"literal_comment_pattern":"Copyright"
"first_comment_is_literal": true,
"literal_comment_pattern": "Copyright"
}
26 changes: 13 additions & 13 deletions .codacy.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
---
engines:
rubocop:
enabled: true
duplication:
enabled: true
metrics:
enabled: true
coverage:
enabled: false
rubocop:
enabled: true
duplication:
enabled: true
metrics:
enabled: true
coverage:
enabled: false
languages:

exclude_paths:
- ThirdParty/**/*
- ThirdParty/*
- scripts/**/*
- scripts/*

- 'ThirdParty/**/*'
- 'ThirdParty/*'
- 'scripts/**/*'
- 'scripts/*'
- '**.md'
12 changes: 6 additions & 6 deletions .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ codecov:
coverage:
precision: 2
round: down
range: "70...100"
range: '70...100'

test:
target: 100%
Expand All @@ -24,12 +24,12 @@ parsers:
macro: no

comment:
layout: "header, diff"
layout: 'header, diff'
behavior: default
require_changes: no

ignore:
- "ThirdParty"
- "examples"
- "test"
- "FuzzTargets"
- 'ThirdParty'
- 'examples'
- 'test'
- 'FuzzTargets'
2 changes: 1 addition & 1 deletion .github/actions/cmake_config/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ inputs:
options:
description: 'The CMake configuration options'
required: false
default: ""
default: ''
name: 'Configure with CMake'
runs:
using: 'docker'
Expand Down
15 changes: 15 additions & 0 deletions .github/actions/create-file-update-pr/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM alpine:latest

RUN apk add --no-cache \
bash \
jq \
git \
ca-certificates \
curl

COPY entrypoint.sh /entrypoint.sh

LABEL name="create-file-pr"
LABEL version="1.0.1"

ENTRYPOINT ["/entrypoint.sh"]
12 changes: 12 additions & 0 deletions .github/actions/create-file-update-pr/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: 'Create File Update PR'
description: 'Pushes a new branch with changed files and opens a PR for updating the changed files in the base branch'
inputs:
no-hash: # turn off inclusion of the hash in the created branch name
description: 'Do not include the changed file hash in the PR branch name'
default: false
replace-branch: # if a PR branch already exists, replaces it with updated contents
description: 'Replace the contents of an existing PR branch of the same name'
default: false
runs:
using: 'docker'
image: 'Dockerfile'
72 changes: 72 additions & 0 deletions .github/actions/create-file-update-pr/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/bin/bash

PR_URL=$(jq --raw-output .repository.pulls_url "$GITHUB_EVENT_PATH")
PR_URL=${PR_URL%\{*}
API_VERSION=v3
API_HEADER="Accept: application/vnd.github.${API_VERSION}+json; application/vnd.github.shadow-cat-preview+json; application/vnd.github.symmetra-preview+json; application/vnd.github.sailor-v-preview+json"
AUTH_HEADER="Authorization: token ${GITHUB_TOKEN}"

# Only commit and open a PR if files have changed
files_changed=$(git diff --staged --name-only)
if [[ "$files_changed" != "" ]];
then
hash=$(sha256sum "${files_changed}" | sha256sum | cut -c 1-12 -)
if [[ "${GITHUB_REF}" == "refs/pull/"* ]];
then
current_branch="${GITHUB_HEAD_REF}"
else
current_branch="${GITHUB_REF#refs/heads/}"
fi

# Set the git origin url for committing using a GITHUB_TOKEN
git remote set-url origin "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}"
git config user.name "${INPUT_GIT_NAME}"
git config user.email "${INPUT_GIT_EMAIL}"

# Construct the branch name with the changes for a PR
pr_branch="${INPUT_BRANCH_PREFIX}update-${current_branch}"
if [[ "${INPUT_NO_HASH}" != "true" ]];
then
pr_branch="${pr_branch}-${hash}"
fi

# Make sure a branch with the same name doesn't already exist, unless INPUT_REPLACE_BRANCH is true
git ls-remote --exit-code . "origin/${pr_branch}"
rv=$?
if [[ "$rv" == "0" ]];
then
if [[ "${INPUT_REPLACE_BRANCH}" != "true" ]];
then
exit 0
fi
pr_branch_exists="true"
fi

if [[ "${pr_branch_exists}" == "true" ]];
then
# delete any existing local branch with the same name
git branch -D "${pr_branch}" >/dev/null 2>&1
fi

# Commit the changed files and push the branch to GitHub
git checkout -b "${pr_branch}"
git commit -m "${INPUT_COMMIT_MSG}"
git push -f -u origin "${pr_branch}"

if [[ "$pr_branch_exists" != "true" ]];
then
# Format string values for GitHub API JSON payload
PR_TITLE="$(echo -n "${INPUT_PR_TITLE}" | jq --raw-input --slurp ".")"
PR_BODY="$(echo -n "${INPUT_PR_BODY}" | jq --raw-input --slurp ".")"
PR_BASE="$(echo -n "${current_branch}" | jq --raw-input --slurp ".")"
PR_HEAD="$(echo -n "${pr_branch}" | jq --raw-input --slurp ".")"
pr_api_data="{\"title\":${PR_TITLE}, \"body\":${PR_BODY}, \"base\":${PR_BASE}, \"head\":${PR_HEAD}, \"draft\":false}"

# Open up the GitHub PR
curl -XPOST -fsSL \
-H "${AUTH_HEADER}" \
-H "${API_HEADER}" \
--data "${pr_api_data}" \
"${PR_URL}"
fi
fi
24 changes: 24 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,30 @@ jobs:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
- uses: pre-commit/action@v1.0.0
- name: Stage changed files
if: failure() && github.event.pull_request.draft != true && github.event.pull_request.head.repo.full_name == github.repository
shell: bash --noprofile --norc {0}
run: |
git diff --name-only
if [[ "$?" == "0" ]];
then
git add --all
fi
exit 0
- name: Create/update a file update PR with no hash
if: failure() && github.event.pull_request.draft != true && github.event.pull_request.head.repo.full_name == github.repository
uses: ./.github/actions/create-file-update-pr
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
COMMIT_MSG: "Automated formatting of files"
PR_TITLE: "Automated formatting of files"
PR_BODY: "Automated formatting of files in commit /~https://github.com/${{ github.event.pull_request.head.repo.full_name }}/commit/${{ github.sha }} from ${{ github.ref }}."
GIT_EMAIL: "HELICS-bot@users.noreply.github.com"
GIT_NAME: "HELICS-bot"
BRANCH_PREFIX: "pre-commit/"
NO_HASH: "true"
REPLACE_BRANCH: "true"

cmake-config:
name: CMake config check
Expand Down
Loading

0 comments on commit 5a329cd

Please sign in to comment.