Skip to content

Commit

Permalink
Merge pull request #1 from nnichols/initial-build
Browse files Browse the repository at this point in the history
Create GitHub action to auto-update tools.deps dependencies
  • Loading branch information
nnichols committed Jan 7, 2021
2 parents 2c8b2d3 + d878a27 commit 054fa29
Show file tree
Hide file tree
Showing 12 changed files with 350 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.{yml,yaml,json}]
indent_size = 2

[Makefile]
indent_style = tab
34 changes: 34 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
name: Bug report
about: Create a report to help us improve

---

# Bug Report

## Describe the Bug

A clear and concise description of what the bug is.

### Steps to Reproduce

Steps to reproduce the behavior:

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

### Expected Behavior

A clear and concise description of what you expected to happen.

### User Information

- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

### Additional Context

Add any other context about the problem here.
23 changes: 23 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
name: Feature request
about: Suggest an idea for this project

---

# Feature Request

## Problem Statement

A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

## Ideal Solution

A clear and concise description of what you want to happen.

### Alternative solutions

A clear and concise description of any alternative solutions or features you've considered.

## Additional Context

Add any other context or screenshots about the feature request here.
9 changes: 9 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Changes proposed in this merge request:
- Additions:
- Updates:
- Deletions:

### Pre-merge Checklist
- [ ] Write + run tests
- [ ] Update documentation
- [ ] Update CHANGELOG and increment version
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Changelog

## v1 - 01/06/2021

- Initial Implementation
52 changes: 52 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community.
Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
Representation of a project may be further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at nichols1991@gmail.com.
All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances.
The project team is obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see https://www.contributor-covenant.org/faq
32 changes: 32 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Contributing

When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change.

Please note we have a code of conduct, please follow it in all your interactions with the project.

## Pull Requests

1. Update the [CHANGELOG.md](https://github.com/nnichols/clojure-dependency-update-action/blob/master/CHANGELOG.md) with details of all changes.
2. If any changes impact the external interface or use of **nnichols**, please update the [README](https://github.com/nnichols/clojure-dependency-update-action/blob/master/README.md) to reflect any relevant differences.
3. Update all version numbers to the new version that this Pull Request would represent.
The versioning scheme we use is [SemVer](http://semver.org/).

### Read the Documentation

Familiarize yourself with the documentation before you submit a Pull Request.
If you have questions which aren't in the documentation, open a ticket or submit a Pull Request to update the documentation.

### How to Contribute

If you're looking for ways to contribute, try adding/fixing tests.
Additionally improving documentation or adding examples as you learn a new project can is an easy way to pitch in.
If you're looking to pitch in more extensively, check out the open [issues and feature requests](https://github.com/nnichols/clojure-dependency-update-action/issues) and take a crack at one of them.

## Code of Conduct

### Our Pledge

In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.

A full copy of our [code of conduct may be found here.](https://github.com/nnichols/clojure-dependency-update-action/blob/master/CODE_OF_CONDUCT.md)
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM uochan/antq AS BASE

LABEL "com.github.actions.name"="Clojure Dependency Update Action"
LABEL "com.github.actions.description"="A simple GitHub Actions to create Pull Requests for outdated tools.deps dependencies"
LABEL "com.github.actions.color"="purple"
LABEL "com.github.actions.icon"="git-pull-request"

LABEL "repository"="https://github.com/nnichols/clojure-dependency-update-action"
LABEL "homepage"="https://github.com/nnichols"
LABEL "maintainer"="Nick Nichols <nichols1991@gmail.com>"

RUN apt update -y
RUN apt install --no-install-recommends -y gnupg2 software-properties-common
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-key C99B11DEB97541F0
RUN apt-add-repository https://cli.github.com/packages
RUN apt update -y
RUN apt install -y gh git

COPY dependency-check.sh /dependency-check.sh

ENTRYPOINT ["bash", "/dependency-check.sh"]
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Nick A Nichols

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,41 @@
# Clojure Dependency Update Action

A simple GitHub action to create Pull Requests for your out-of-date tools.deps dependencies.

This action uses [antq](https://github.com/liquidz/antq) to check dependencies.

## Sample Usage

```yml
name: Clojure Dependency Checking

on: [push]

jobs:
build:

runs-on: ubuntu-latest

steps:
- name: Checkout Latest Commit
uses: actions/checkout@v1

- name: Check deps
uses: nnichols/clojure-dependency-update-action@96977263899a0e5b374ce921cea8269c0aa0a515
with:
github-token: ${{ secrets.github_token }}
```

## Supported Arguments

* `github-token`: The only required argument. Can either be the default token, as seen above, or a personal access token with write access to the repository.
* `branch`: The branch that dependencies should be checked on and Pull Requests created against. Defaults to `master`
* `git-email`: The email address each commit should be associated with. Defaults to a github provided noreply address
* `git-username`: The GitHub username each commit should be associated with. Defaults to `github-actions[bot]`
* `excludes`: Artifact names to be excluded from the `antq` check. Defaults to an empty list. See [antq-action](https://github.com/liquidz/antq-action#inputs) for more information.
* `directories`: Directories to search for project files in. Defaults to the root of the repository. See [antq-action](https://github.com/liquidz/antq-action#inputs) for more information.
* `skips`: Build tools/files to skip by default. Defaults to an empty list. See [antq-action](https://github.com/liquidz/antq-action#inputs) for more information.

## Acknowledgements

Special thanks to [Chad Taylor](https://github.com/tessellator) for figuring out the initial bash script this is based on.
50 changes: 50 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# ref: https://help.github.com/en/actions/building-actions/metadata-syntax-for-github-actions
name: Clojure Dependency Update Action
description: A simple GitHub Actions to create Pull Requests for outdated tools.deps dependencies

author: Nick Nichols

branding:
color: purple
icon: git-pull-request

inputs:
github-token:
description: A GitHub auth token to be able to create the pull request
required: true
branch:
description: the branch to commit to
required: true
default: master
git-email:
description: 'The email address used to create the version commit with.'
required: true
default: 41898282+github-actions[bot]@users.noreply.github.com
git-username:
description: 'The name to use for the version commit. e.g. github.actor'
required: true
default: github-actions[bot]
excludes:
description: 'Artifact names to exclude (space separated).'
required: true
default: ''
directories:
description: 'Search paths for projects (space separated).'
required: true
default: ''
skips:
description: 'Project types to skip to search (space separated). Must be one of `boot`, `clojure-cli`, `github-action`, `pom`, `shadow-cljs` and `leiningen`.'
required: true
default: ''

runs:
using: docker
image: Dockerfile
env:
TOKEN: ${{ inputs.github-token }}
EMAIL: ${{ inputs.git-email }}
NAME: ${{ inputs.git-username }}
BRANCH: ${{ inputs.branch }}
EXCLUDE: ${{ inputs.excludes }}
DIRECTORY: ${{ inputs.directories }}
SKIP: ${{ inputs.skips }}
45 changes: 45 additions & 0 deletions dependency-check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash

git config --global user.email $EMAIL
git config --global user.name $NAME
export GITHUB_TOKEN=$TOKEN
git checkout $BRANCH

EXCLUDES=""
for artifact in $EXCLUDE; do
EXCLUDES="${EXCLUDES} --exclude=${artifact}"
done

DIRECTORIES=""
for directory in $DIRECTORY; do
DIRECTORIES="${DIRECTORIES} --directory=${directory}"
done

SKIPS=""
for skip in $SKIP; do
SKIPS="${SKIPS} --skip=${skip}"
done

PREFETCH=$(clojure -Stree -Sdeps '{:deps {antq/antq {:mvn/version "RELEASE"}}}')
UPGRADES=$(clojure -Sdeps '{:deps {antq/antq {:mvn/version "RELEASE"}}}' -m antq.core --reporter=format --error-format="{{name}},{{version}},{{latest-version}}" $EXCLUDES $DIRECTORIES $SKIPS | sed '/Failed to fetch/d' | sed '/Unable to fetch/d' | sed '/Logging initialized/d')

for upgrade in $UPGRADES; do
IFS=',' temp=($upgrade)
DEP_NAME=${temp[0]}
OLD_VERSION=${temp[1]}
NEW_VERSION=${temp[2]}
BRANCH_NAME="dependencies/clojure/$DEP_NAME-$NEW_VERSION"
echo "Updating" $DEP_NAME "version" $OLD_VERSION "to" $NEW_VERSION
git checkout -b $BRANCH_NAME
if [[ $? == 0 ]]; then
ESCAPED_DEP_NAME=`echo $DEP_NAME | sed 's/\//\\\\\//'`
sed -e "/$ESCAPED_DEP_NAME/s/$OLD_VERSION/$NEW_VERSION/" deps.edn > deps2.edn
mv deps2.edn deps.edn
git add deps.edn
git commit -m "Bump $DEP_NAME from $OLD_VERSION to $NEW_VERSION"
git push -u "https://$GITHUB_ACTOR:$TOKEN@github.com/$GITHUB_REPOSITORY.git" $BRANCH_NAME
gh pr create --fill --head $BRANCH_NAME --base $BRANCH
echo
git checkout $BRANCH
fi
done

0 comments on commit 054fa29

Please sign in to comment.