Skip to content

Commit

Permalink
Sync workflow and readme with the template repository
Browse files Browse the repository at this point in the history
This adds a new pre-commit checker (`pre-commit install` to set up locally)
  • Loading branch information
arichardson committed Jan 27, 2024
1 parent b87760e commit 9b41bba
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 50 deletions.
95 changes: 48 additions & 47 deletions .github/workflows/build-pdf.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
name: Create Specification Document

# The workflow is triggered by pull request, push to main, and manual dispatch.
Expand All @@ -9,22 +10,22 @@ on:
required: true
type: string
revision_mark:
description: 'Set revision mark as Draft, Release or Stable:'
required: true
type: string
default: 'Draft'
description: 'Set revision mark as Draft, Release or Stable:'
required: true
type: string
default: Draft
prerelease:
description: 'Tag as a pre-release?'
description: Tag as a pre-release?
required: false
type: boolean
default: true
draft:
description: 'Create release as a draft?'
description: Create release as a draft?
required: false
type: boolean
default: false
pages:
description: 'Deploy HTML to Github pages?'
description: Deploy HTML to Github pages?
required: false
type: boolean
default: false
Expand All @@ -39,57 +40,57 @@ jobs:

steps:
# Checkout the repository
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: recursive

# Pull the latest RISC-V Docs container image
- name: Pull Container
run: docker pull riscvintl/riscv-docs-base-container-image:latest
- name: Pull Container
run: docker pull riscvintl/riscv-docs-base-container-image:latest

# Build PDF and HTML.
- name: Build Files
run: make all
env:
VERSION: v${{ github.event.inputs.version }}
REVMARK: ${{ github.event.inputs.revision_mark }}
- name: Build Files
run: make all
env:
VERSION: v${{ github.event.inputs.version }}
REVMARK: ${{ github.event.inputs.revision_mark }}

# Upload the built PDF and HTML files as a single artifact
- name: Upload Build Artifacts
uses: actions/upload-artifact@v3
with:
name: Build Artifacts
path: |
build/*.pdf
build/*.html
retention-days: 30
- name: Upload Build Artifacts
uses: actions/upload-artifact@v3
with:
name: Build Artifacts
path: |
build/*.pdf
build/*.html
retention-days: 30

# Upload gitlab pages artefact.
- name: Make gitlab pages directory
run: mkdir dist && cp build/*.html dist/index.html
if: github.event_name == 'workflow_dispatch'
- name: Make gitlab pages directory
run: mkdir dist && cp build/*.html dist/index.html
if: github.event_name == 'workflow_dispatch'

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: dist
if: github.event_name == 'workflow_dispatch'
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: dist
if: github.event_name == 'workflow_dispatch'

# Create Release
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: |
build/*.pdf
build/*.html
tag_name: v${{ github.event.inputs.version }}
name: Release ${{ github.event.inputs.version }}
draft: ${{ github.event.inputs.draft }}
prerelease: ${{ github.event.inputs.prerelease }}
env:
GITHUB_TOKEN: ${{ secrets.GHTOKEN }}
if: github.event_name == 'workflow_dispatch'
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: |
build/*.pdf
build/*.html
tag_name: v${{ github.event.inputs.version }}
name: Release ${{ github.event.inputs.version }}
draft: ${{ github.event.inputs.draft }}
prerelease: ${{ github.event.inputs.prerelease }}
env:
GITHUB_TOKEN: ${{ secrets.GHTOKEN }}
if: github.event_name == 'workflow_dispatch'
# This condition ensures this step only runs for workflow_dispatch events.

# Deploy HTML to Github pages.
Expand Down
15 changes: 15 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
name: pre-commit

on:
pull_request:
push:
branches: [main]

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- uses: pre-commit/[email protected]
26 changes: 26 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-json
- id: check-symlinks
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]

- repo: local
hooks:
- id: forbidden-file-extensions
name: forbidden-file-extensions
entry: disallow these file extensions
language: fail
# Disallow other asciidoc extensions except .adoc
files: .*\.(asciidoc|asc)$

- repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt
rev: 0.2.3
hooks:
- id: yamlfmt
args: [--mapping, '2', --sequence, '4', --offset, '2']
8 changes: 5 additions & 3 deletions readme.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This work is licensed under a Creative Commons Attribution 4.0 International Lic

== Contributors

The list of contributors to this specification is maintained in the link:contributors.adoc[contributors] file.
The list of contributors to this specification is maintained in the link:src/contributors.adoc[contributors] file.

For guidelines on how to contribute, refer to the link:CONTRIBUTING.md[CONTRIBUTING] file.

Expand All @@ -25,13 +25,15 @@ To build the document, you'll need the following tools installed on your system:

=== Cloning the Repository

`git clone --recurse-submodules https://github.com/riscv/riscv-cheri.git`
```shell
git clone --recurse-submodules https://github.com/riscv/riscv-cheri.git
```

=== Building the Documentation

To start the build process, run `cd ./riscv-cheri && make all`.

The Makefile script will check the availability of Docker on your system:
The link:Makefile[] script will check the availability of Docker on your system:

* If Docker is available, the documentation will be built inside a Docker container using the image riscvintl/riscv-docs-base-container-image:latest. This ensures a consistent build environment across different systems.
* If Docker is not available, the documentation will be built directly on your system using the installed tools.
Expand Down

0 comments on commit 9b41bba

Please sign in to comment.