From 254503d26d2050a54c4aa84d266abd26c2066c29 Mon Sep 17 00:00:00 2001 From: Chevdor Date: Tue, 28 Feb 2023 15:47:26 +0100 Subject: [PATCH 1/5] Use asciidoc for the doc to remain readable --- README.md | 389 +++++++++++++++++++++++++++---------- README_src.adoc | 19 ++ doc/contributing.adoc | 91 +++++++++ doc/crate-reservation.adoc | 9 + doc/usage.adoc | 40 ++++ justfile | 17 +- 6 files changed, 453 insertions(+), 112 deletions(-) create mode 100644 README_src.adoc create mode 100644 doc/contributing.adoc create mode 100644 doc/crate-reservation.adoc create mode 100644 doc/usage.adoc diff --git a/README.md b/README.md index 4a8d284..31ef32b 100644 --- a/README.md +++ b/README.md @@ -1,142 +1,117 @@ -# TOC - -- [Introduction](#introduction) -- [Reserving crates](#reserving-crates) -- [Usage](#usage) - - [GitHub Actions](#usage-github-actions) - - [GitLab Jobs](#usage-gitlab-jobs) - - [Locally](#usage-locally) -- [Development](#development) - - [Repository structure](#development-repository-structure) - - [External consumption](#development-repository-structure-external-consumption) - - [Tools](#development-repository-structure-tools) - - [Maintenance](#development-repository-structure-maintenance) - - [Tests](#development-tests) - - [Linters](#development-linters) - - [S3](#development-s3) - -# Introduction - -This repository contains scripts managed and used by -[release-engineering](https://github.com/orgs/paritytech/teams/release-engineering). +# Introduction + +This repository contains scripts managed and used by [release-engineering](https://github.com/orgs/paritytech/teams/release-engineering). See the [Tools wiki page](https://github.com/paritytech/releng-scripts/wiki/Tools#TOC) for information on the functionality provided through this repository. -# Reserving crates +# Reserving crates + +1. Go to + +2. Click the "Run workflow" button to access the workflow’s form -1. Go to https://github.com/paritytech/releng-scripts/actions/workflows/reserve-crate.yml -2. Click the "Run workflow" button to access the workflow's form -3. Fill and send the workflow's form. After that a workflow run - ([example](https://github.com/paritytech/releng-scripts/actions/runs/3642900863/attempts/1)) - will be created; you might need to refresh the page in order to see it. -4. Wait for the workflow run to finish +3. Fill and send the workflow’s form. After that a workflow run + ([example](https://github.com/paritytech/releng-scripts/actions/runs/3642900863/attempts/1)) + will be created; you might need to refresh the page in order to see it. -# Usage +4. Wait for the workflow run to finish + +# Usage ## Docker Once the automation is in place, the image will be available as `paritytech/releng-scripts` and usable as: -```bash -# Show the help -docker run --rm -it paritytech/releng-scripts -# Show the version -docker run --rm -it paritytech/releng-scripts version -``` - -## GitHub Actions - -```yaml -jobs: - upload-artifact: - name: My workflow - runs-on: ubuntu-latest - steps: - - name: First step - run: | - git clone --depth=1 https://github.com/paritytech/releng-scripts - ./releng-scripts/foo ... -``` - -## GitLab Jobs - -```yaml -job: - script: - - git clone --depth=1 https://github.com/paritytech/releng-scripts - - ./releng-scripts/foo ... -``` - -## Locally + # Show the help + docker run --rm -it paritytech/releng-scripts + # Show the version + docker run --rm -it paritytech/releng-scripts version + +## GitHub Actions + + jobs: + upload-artifact: + name: My workflow + runs-on: ubuntu-latest + steps: + - name: First step + run: | + git clone --depth=1 https://github.com/paritytech/releng-scripts + ./releng-scripts/foo ... + +## GitLab Jobs + + job: + script: + - git clone --depth=1 https://github.com/paritytech/releng-scripts + - ./releng-scripts/foo ... + +## Locally Clone this repository and run the scripts -# Development +# Contributing -## Repository structure +## Repository structure -### External consumption +### External consumption If a script is meant for external consumption, such as the tools' entrypoints, -then avoid adding file extensions to them since that's more subject to breaking -changes in case we want to change the script's programming language later. +then avoid adding file extensions to them since that’s more subject to breaking +changes in case we want to change the script’s programming language later. Adding the extension is encouraged for files which are not meant for external consumption, i.e. scripts which are used only internally or are run through some command runner such as `just`. -Here's an example: +Here’s an example: -``` -/repository -├── cmd -│ └── rs -│ └── upload.sh -└── rs -``` + /repository + ├── cmd + │ └── rs + │ └── upload.sh + └── rs -`rs` is a tool entrypoint meant for external consumption, therefore it doesn't +`rs` is a tool entrypoint meant for external consumption, therefore it doesn’t include an extension. On the other hand, `upload.sh`, which corresponds to the -`upload` subcommand of `rs`, can keep its extension because it's not meant for -external consumption, as it's invoked by `rs`. +`upload` subcommand of `rs`, can keep its extension because it’s not meant for +external consumption, as it’s invoked by `rs`. -### Tools +### Tools Tools are organized with the following hierarchy: -- Their entrypoints are located at the root of the repository for - ease-of-external-consumption's sake. +- Their entrypoints are located at the root of the repository for + ease-of-external-consumption’s sake. - Avoid including the extension to those files because that's more subject to - breaking changes in case we want to change the tool's programming language - later. + Avoid including the extension to those files because that's more subject to + breaking changes in case we want to change the tool's programming language + later. - Please maintain an entry to the tools in `./justfile` for ease-of-use's sake. + Please maintain an entry to the tools in `./justfile` for ease-of-use's sake. -- In case the tool has subcommands, they are located at `./cmd/$TOOL/$SUBCOMMAND` +- In case the tool has subcommands, they are located at `./cmd/$TOOL/$SUBCOMMAND` - This is to avoid noisy handling of too many commands within a single file. + This is to avoid noisy handling of too many commands within a single file. -Here's an example: +Here’s an example: -``` -/repository -├── cmd -│ └── rs -│ └── upload.sh -└── rs -``` + /repository + ├── cmd + │ └── rs + │ └── upload.sh + └── rs -`rs` is the tool's entrypoint and `upload.sh` corresponds to the `upload` +`rs` is the tool’s entrypoint and `upload.sh` corresponds to the `upload` subcommand of `rs`. -### Maintenance +### Maintenance The `./tasks` directory groups scripts for tasks related to project maintenance, such as running linters and tests. -Please maintain an entry to those scripts in `./justfile` for ease-of-use's sake. +Please maintain an entry to those scripts in `./justfile` for ease-of-use’s sake. -## Tests +## Tests Run the test: `just tests` @@ -144,22 +119,20 @@ Update the snapshots: `just tests --update` Delete stale snapshots: `just tests --delete-stale-snapshots` -## Linters +## Linters `just linters` -## S3 +## S3 -For testing out the S3 backend you can use https://github.com/adobe/S3Mock. +For testing out the S3 backend you can use [S3Mock](https://github.com/adobe/S3Mock). Set up the following environment variables: -``` -export AWS_ACCESS_KEY_ID=1234567890 -export AWS_SECRET_ACCESS_KEY=valid-test-key-ref -export AWS_DEFAULT_REGION=us-east-1 -export AWS_BUCKET=test -``` + export AWS_ACCESS_KEY_ID=1234567890 + export AWS_SECRET_ACCESS_KEY=valid-test-key-ref + export AWS_DEFAULT_REGION=us-east-1 + export AWS_BUCKET=test Then start S3Mock: @@ -168,3 +141,207 @@ Then start S3Mock: Then try to upload a file: `just rs upload custom foo/bar s3 --s3mock tests/fixtures/foo.txt` + +## License + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/README_src.adoc b/README_src.adoc new file mode 100644 index 0000000..59b981f --- /dev/null +++ b/README_src.adoc @@ -0,0 +1,19 @@ +:toc: + +== Introduction + +This repository contains scripts managed and used by https://github.com/orgs/paritytech/teams/release-engineering[release-engineering]. + +See the https://github.com/paritytech/releng-scripts/wiki/Tools#TOC[Tools wiki page] for information on the functionality provided through this repository. + +include::doc/crate-reservation.adoc[leveloffset=+1] + +include::doc/usage.adoc[leveloffset=+1] + +include::doc/contributing.adoc[leveloffset=+1] + +== License + +---- +include::LICENSE[] +---- diff --git a/doc/contributing.adoc b/doc/contributing.adoc new file mode 100644 index 0000000..ede1904 --- /dev/null +++ b/doc/contributing.adoc @@ -0,0 +1,91 @@ += Contributing + +== Repository structure + +=== External consumption + +If a script is meant for external consumption, such as the tools' entrypoints, +then avoid adding file extensions to them since that's more subject to breaking +changes in case we want to change the script's programming language later. +Adding the extension is encouraged for files which are not meant for external +consumption, i.e. scripts which are used only internally or are run through some +command runner such as `just`. + +Here's an example: + + /repository + ├── cmd + │ └── rs + │ └── upload.sh + └── rs + +`rs` is a tool entrypoint meant for external consumption, therefore it doesn't +include an extension. On the other hand, `upload.sh`, which corresponds to the +`upload` subcommand of `rs`, can keep its extension because it's not meant for +external consumption, as it's invoked by `rs`. + +=== Tools + +Tools are organized with the following hierarchy: + +- Their entrypoints are located at the root of the repository for + ease-of-external-consumption's sake. + + Avoid including the extension to those files because that's more subject to + breaking changes in case we want to change the tool's programming language + later. + + Please maintain an entry to the tools in `./justfile` for ease-of-use's sake. + +- In case the tool has subcommands, they are located at `./cmd/$TOOL/$SUBCOMMAND` + + This is to avoid noisy handling of too many commands within a single file. + +Here's an example: + + /repository + ├── cmd + │ └── rs + │ └── upload.sh + └── rs + +`rs` is the tool's entrypoint and `upload.sh` corresponds to the `upload` +subcommand of `rs`. + +=== Maintenance + +The `./tasks` directory groups scripts for tasks related to project maintenance, +such as running linters and tests. + +Please maintain an entry to those scripts in `./justfile` for ease-of-use's sake. + +== Tests + +Run the test: `just tests` + +Update the snapshots: `just tests --update` + +Delete stale snapshots: `just tests --delete-stale-snapshots` + +== Linters + +`just linters` + +== S3 + +For testing out the S3 backend you can use https://github.com/adobe/S3Mock[S3Mock]. + +Set up the following environment variables: + + export AWS_ACCESS_KEY_ID=1234567890 + export AWS_SECRET_ACCESS_KEY=valid-test-key-ref + export AWS_DEFAULT_REGION=us-east-1 + export AWS_BUCKET=test + +Then start S3Mock: + +`./tasks/start-s3-mock.sh` + +Then try to upload a file: + +`just rs upload custom foo/bar s3 --s3mock tests/fixtures/foo.txt` diff --git a/doc/crate-reservation.adoc b/doc/crate-reservation.adoc new file mode 100644 index 0000000..1baf9f7 --- /dev/null +++ b/doc/crate-reservation.adoc @@ -0,0 +1,9 @@ + += Reserving crates + +. Go to https://github.com/paritytech/releng-scripts/actions/workflows/reserve-crate.yml +. Click the "Run workflow" button to access the workflow's form +. Fill and send the workflow's form. After that a workflow run + (https://github.com/paritytech/releng-scripts/actions/runs/3642900863/attempts/1[example]) + will be created; you might need to refresh the page in order to see it. +. Wait for the workflow run to finish diff --git a/doc/usage.adoc b/doc/usage.adoc new file mode 100644 index 0000000..a69d010 --- /dev/null +++ b/doc/usage.adoc @@ -0,0 +1,40 @@ + += Usage + +== Docker + +Once the automation is in place, the image will be available as `paritytech/releng-scripts` and usable as: + +```bash +# Show the help +docker run --rm -it paritytech/releng-scripts +# Show the version +docker run --rm -it paritytech/releng-scripts version +``` + +== GitHub Actions + +```yaml +jobs: + upload-artifact: + name: My workflow + runs-on: ubuntu-latest + steps: + - name: First step + run: | + git clone --depth=1 https://github.com/paritytech/releng-scripts + ./releng-scripts/foo ... +``` + +== GitLab Jobs + +```yaml +job: + script: + - git clone --depth=1 https://github.com/paritytech/releng-scripts + - ./releng-scripts/foo ... +``` + +== Locally + +Clone this repository and run the scripts diff --git a/justfile b/justfile index 1f8aecf..2ca7a46 100644 --- a/justfile +++ b/justfile @@ -6,16 +6,15 @@ default_owner := "paritytech" _default: just --choose --chooser "fzf +s -x --tac --cycle" +# Install required tooling +setup: + pip install pre-commit + # Show some help help: just --list -tests *args: - ./tasks/tests.sh "$@" - -linters *args: - ./tasks/linters.sh "$@" - +# Run rs rs *args: ./rs "$@" @@ -24,6 +23,7 @@ build_docker_image owner=default_owner: docker build -t $docker_image_name -t {{owner}}/$docker_image_name . docker images | grep "releng" +# Run using docker run *args: docker run --rm -it rs "$@" @@ -33,3 +33,8 @@ publish_docker_image owner=default_owner: (build_docker_image owner) # Publish everything publish: publish_docker_image + +# Generate the readme as Markdown file +md: + #!/usr/bin/env bash + asciidoctor -b docbook -a leveloffset=+1 -o - README_src.adoc | pandoc --markdown-headings=atx --wrap=preserve -t markdown_strict -f docbook - > README.md From 9b9b1dee5d8da8046b706a9b2d15d887c5d1bcd1 Mon Sep 17 00:00:00 2001 From: Chevdor Date: Tue, 28 Feb 2023 16:05:31 +0100 Subject: [PATCH 2/5] Add some doc --- README.md | 29 +++++++++++++++++++++++++++++ README_src.adoc | 2 ++ doc/rs-delete.adoc | 4 ++++ doc/rs-download.adoc | 4 ++++ doc/rs-upload.adoc | 4 ++++ doc/rs-version.adoc | 10 ++++++++++ doc/rs.adoc | 14 ++++++++++++++ 7 files changed, 67 insertions(+) create mode 100644 doc/rs-delete.adoc create mode 100644 doc/rs-download.adoc create mode 100644 doc/rs-upload.adoc create mode 100644 doc/rs-version.adoc create mode 100644 doc/rs.adoc diff --git a/README.md b/README.md index 31ef32b..e3611dd 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,35 @@ This repository contains scripts managed and used by [release-engineering](https See the [Tools wiki page](https://github.com/paritytech/releng-scripts/wiki/Tools#TOC) for information on the functionality provided through this repository. +# rs + +The commands offerered by `rs` can be access via script, GHS, Docker, etc.. +Those use case are described in the documentation. + +The following chapters explain what those commands **are** and how to use them. + +# `rs version` + +Get the version: + + docker run --rm -it paritytech/releng-scripts version + +output: + + 0.0.1 + +# `rs upload` + +Uplooad an artifact. + +# `rs download` + +Download an artifact. + +# `rs delete` + +Delete an artifact. + # Reserving crates 1. Go to diff --git a/README_src.adoc b/README_src.adoc index 59b981f..a871d6f 100644 --- a/README_src.adoc +++ b/README_src.adoc @@ -6,6 +6,8 @@ This repository contains scripts managed and used by https://github.com/orgs/par See the https://github.com/paritytech/releng-scripts/wiki/Tools#TOC[Tools wiki page] for information on the functionality provided through this repository. +include::doc/rs.adoc[] + include::doc/crate-reservation.adoc[leveloffset=+1] include::doc/usage.adoc[leveloffset=+1] diff --git a/doc/rs-delete.adoc b/doc/rs-delete.adoc new file mode 100644 index 0000000..d6069b5 --- /dev/null +++ b/doc/rs-delete.adoc @@ -0,0 +1,4 @@ + +== `rs delete` + +Delete an artifact. diff --git a/doc/rs-download.adoc b/doc/rs-download.adoc new file mode 100644 index 0000000..f4dee13 --- /dev/null +++ b/doc/rs-download.adoc @@ -0,0 +1,4 @@ + +== `rs download` + +Download an artifact. diff --git a/doc/rs-upload.adoc b/doc/rs-upload.adoc new file mode 100644 index 0000000..610062e --- /dev/null +++ b/doc/rs-upload.adoc @@ -0,0 +1,4 @@ + +== `rs upload` + +Uplooad an artifact. diff --git a/doc/rs-version.adoc b/doc/rs-version.adoc new file mode 100644 index 0000000..537edfb --- /dev/null +++ b/doc/rs-version.adoc @@ -0,0 +1,10 @@ + +== `rs version` + +Get the version: + + docker run --rm -it paritytech/releng-scripts version + +output: + + 0.0.1 diff --git a/doc/rs.adoc b/doc/rs.adoc new file mode 100644 index 0000000..aab5abe --- /dev/null +++ b/doc/rs.adoc @@ -0,0 +1,14 @@ +== rs + +The commands offerered by `rs` can be access via script, GHS, Docker, etc.. +Those use case are described in the documentation. + +The following chapters explain what those commands **are** and how to use them. + +include::rs-version.adoc[leveloffset=+1] + +include::rs-upload.adoc[leveloffset=+1] + +include::rs-download.adoc[leveloffset=+1] + +include::rs-delete.adoc[leveloffset=+1] From 26ed7729d4a9a0e2c76da235b66a2bed8bbfafd9 Mon Sep 17 00:00:00 2001 From: Chevdor Date: Tue, 28 Feb 2023 18:13:39 +0100 Subject: [PATCH 3/5] WIP --- Dockerfile | 39 +++++++++++++++++++++++++++++++++++++++ README.md | 10 +++++++++- cmd/rs/upload.sh | 8 ++++++-- doc/rs-upload.adoc | 4 ++++ doc/rs.adoc | 6 +++++- 5 files changed, 63 insertions(+), 4 deletions(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1eb5c76 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,39 @@ +ARG REGISTRY_PATH=docker.io/paritytech + +FROM docker.io/library/ubuntu:latest + +ARG VCS_REF=master +ARG BUILD_DATE="" +ARG UID=1000 +ARG GID=1000 +ARG VERSION=0.0.1 + +LABEL summary="Releng scripts" \ + name="${REGISTRY_PATH}/gnupg" \ + maintainer="devops-team@parity.io" \ + version="${VERSION}" \ + description="Releng scripts" \ + io.parity.image.vendor="Parity Technologies" \ + io.parity.image.source="https://github.com/paritytech/scripts/blob/${VCS_REF}/dockerfiles/releng-scripts/Dockerfile" \ + io.parity.image.documentation="https://github.com/paritytech/scripts/blob/${VCS_REF}/dockerfiles/releng-scripts/README.md" \ + io.parity.image.revision="${VCS_REF}" \ + io.parity.image.created="${BUILD_DATE}" + +RUN apt-get update && apt-get install -yq --no-install-recommends ca-certificates bash jq unzip curl && \ + curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "/tmp/awscliv2.zip" && \ + unzip "/tmp/awscliv2.zip" && rm "/tmp/awscliv2.zip" && \ + /aws/install && rm -rf /aws && \ + apt -yq remove ca-certificates unzip && apt -yq autoremove && \ + aws --version + +WORKDIR /scripts + +COPY . . + +RUN set -x \ + && groupadd -g $GID nonroot \ + && useradd -u $UID -g $GID -s /bin/bash -m nonroot + +USER nonroot:nonroot + +ENTRYPOINT [ "./rs" ] diff --git a/README.md b/README.md index 85edbe9..b840e73 100644 --- a/README.md +++ b/README.md @@ -7,10 +7,14 @@ See the [Tools wiki page](https://github.com/paritytech/releng-scripts/wiki/Tool # rs The commands offerered by `rs` can be access via script, GHS, Docker, etc.. -Those use case are described in the documentation. +Those use cases are described in the documentation. The following chapters explain what those commands **are** and how to use them. +You may find convenient testing using: + + alias rs='docker run --rm -it -e AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY -e AWS_DEFAULT_REGION -e AWS_BUCKET paritytech/releng-scripts' + # `rs version` Get the version: @@ -25,6 +29,10 @@ output: Uplooad an artifact. +Check the help with `rs upload --help` + + rs upload --bucket $AWS_BUCKET custom foo/bar s3 tests/fixtures/foo.txt + # `rs download` Download an artifact. diff --git a/cmd/rs/upload.sh b/cmd/rs/upload.sh index 665e509..9bd50d0 100755 --- a/cmd/rs/upload.sh +++ b/cmd/rs/upload.sh @@ -1,5 +1,8 @@ #!/usr/bin/env bash +# requirements: +# jq, aws + set -Eeu -o pipefail shopt -s inherit_errexit @@ -45,7 +48,7 @@ upload_to_s3() { "${backend_upload_args[@]}" "${forwarded_backend_args[@]}" -- - "$file" + "${file}" "$destination" ) @@ -83,6 +86,7 @@ upload_to_s3() { ;; *) log info "Checking metadata for destination $destination" + echo "$response" if echo -n "$response" | jq -e; then # Valid JSON response for metadata, which means that the file exists log error "File already exists: $destination" @@ -222,7 +226,7 @@ main() { local remote_destination="${upload_dir:+$upload_dir/}$filename" if [ ! "${DRY_RUN:-}" ]; then - log "Uploading file: $file" + log "Uploading file: $file to bucket $bucket" log "Upload destination: $remote_destination" fi diff --git a/doc/rs-upload.adoc b/doc/rs-upload.adoc index 610062e..722a122 100644 --- a/doc/rs-upload.adoc +++ b/doc/rs-upload.adoc @@ -2,3 +2,7 @@ == `rs upload` Uplooad an artifact. + +Check the help with `rs upload --help` + + rs upload --bucket $AWS_BUCKET custom foo/bar s3 tests/fixtures/foo.txt diff --git a/doc/rs.adoc b/doc/rs.adoc index aab5abe..7c6822e 100644 --- a/doc/rs.adoc +++ b/doc/rs.adoc @@ -1,10 +1,14 @@ == rs The commands offerered by `rs` can be access via script, GHS, Docker, etc.. -Those use case are described in the documentation. +Those use cases are described in the documentation. The following chapters explain what those commands **are** and how to use them. +You may find convenient testing using: + + alias rs='docker run --rm -it -e AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY -e AWS_DEFAULT_REGION -e AWS_BUCKET paritytech/releng-scripts' + include::rs-version.adoc[leveloffset=+1] include::rs-upload.adoc[leveloffset=+1] From eea12f1d78d73d21c440aeeecff1864afb315f3a Mon Sep 17 00:00:00 2001 From: Chevdor Date: Wed, 1 Mar 2023 15:07:14 +0100 Subject: [PATCH 4/5] Add env example --- .dockerignore | 1 - .env-sample | 7 +++++++ .gitignore | 3 ++- 3 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 .env-sample diff --git a/.dockerignore b/.dockerignore index b4c8c5b..a7721e7 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,5 +1,4 @@ .env* -!.env-sample tests .github .git diff --git a/.env-sample b/.env-sample new file mode 100644 index 0000000..3405b1e --- /dev/null +++ b/.env-sample @@ -0,0 +1,7 @@ +AWS_ACCESS_KEY_ID=... +AWS_SECRET_ACCESS_KEY=... +AWS_DEFAULT_REGION=us-east-1 +AWS_S3_BUCKET=... +AWS_BUCKET="${AWS_S3_BUCKET}" + +HTTP=https://${AWS_S3_BUCKET}.s3.${AWS_DEFAULT_REGION}.amazonaws.com diff --git a/.gitignore b/.gitignore index 0d5a0e1..50baacd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ -.env +.env* +!.env-sample /tests/.cleanup-pids /tests/.snapshots-overwrite /tests/.aws-destinations From cca67fb1ca68a280117dc47a0dfdf90665d8aa9f Mon Sep 17 00:00:00 2001 From: Chevdor Date: Thu, 10 Aug 2023 15:34:38 +0200 Subject: [PATCH 5/5] Fix justfile --- justfile | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/justfile b/justfile index 4bb7884..50e7ffd 100644 --- a/justfile +++ b/justfile @@ -1,5 +1,6 @@ set positional-arguments export docker_image_name := "releng-scripts" +export ENGINE := "podman" default_owner := "paritytech" # List available commands @@ -23,19 +24,23 @@ linters *args: releng-scripts *args: ./releng-scripts "$@" -# Run using docker +# Run as container run *args: - docker run --rm -it releng-scripts "$@" + $ENGINE run --rm -it releng-scripts "$@" + +# Build the docker image +build_docker_image owner=default_owner: + $ENGINE build -t {{owner}}/$docker_image_name . + $ENGINE images | grep {{owner}}/$docker_image_name # Push the docker image publish_docker_image owner=default_owner: (build_docker_image owner) - docker push {{owner}}/$docker_image_name + $ENGINE push {{owner}}/$docker_image_name # Publish everything publish: publish_docker_image # Generate the readme as Markdown file - md: #!/usr/bin/env bash asciidoctor -b docbook -a leveloffset=+1 -o - README_src.adoc | pandoc --markdown-headings=atx --wrap=preserve -t markdown_strict -f docbook - > README.md