Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Add CI for linting docs #998

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions .github/workflows/_filechange_checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ name: Filechange Checker
on:
workflow_call:
outputs:
fileschanged:
srcfileschanged:
description: "'true' if src/** or .github/workflows/** files have changed in the branch"
value: ${{ jobs.file-change-check.outputs.fileschanged }}
value: ${{ jobs.file-change-check.outputs.srcfileschanged }}
docfileschanged:
description: "'true' if docs/** or src/** or .github/workflows/** files have changed in the branch"
value: ${{ jobs.file-change-check.outputs.docfileschanged }}

jobs:
file-change-check:
Expand All @@ -14,7 +17,8 @@ jobs:
contents: read
pull-requests: read
outputs:
fileschanged: ${{ steps.checker.outputs.fileschanged }}
srcfileschanged: ${{ steps.srcchecker.outputs.srcfileschanged }}
docfileschanged: ${{ steps.docchecker.outputs.docfileschanged }}
steps:
- uses: actions/checkout@v3

Expand All @@ -27,11 +31,21 @@ jobs:
filters: |
src:
- 'src/**'
docs:
- 'docs/**'
actions:
- '.github/workflows/**'
- name: Check dorny for changes in specified filepaths
id: checker
- name: Check dorny for changes in src filepaths
id: srcchecker
if: steps.dornycheck.outputs.src == 'true' || steps.dornycheck.outputs.actions == 'true'
run: |
echo "src or workflow file changes occurred"
echo ::set-output name=fileschanged::true
echo ::set-output name=srcfileschanged::true
- name: Check dorny for changes in docs related filepaths
id: docchecker
if: steps.dornycheck.outputs.src == 'true' || steps.dornycheck.outputs.docs == 'true' || steps.dornycheck.outputs.actions == 'true'
ryanfkeepers marked this conversation as resolved.
Show resolved Hide resolved
run: |
echo "docs, src or workflow file changes occurred"
echo ::set-output name=docfileschanged::true
22 changes: 11 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
# --- Prechecks and Checkouts ------------------------------------------------------------------------
# ----------------------------------------------------------------------------------------------------
precheck:
uses: alcionai/corso/.github/workflows/_filechange_checker.yml@main
uses: alcionai/corso/.github/workflows/_filechange_checker.yml@docs-ci # TODO: change this to main

checkout:
needs: precheck
Expand All @@ -35,7 +35,7 @@ jobs:
- uses: actions/checkout@v3

- name: Setup Golang with cache
if: needs.precheck.outputs.fileschanged == 'true'
if: needs.precheck.outputs.srcfileschanged == 'true'
uses: ./.github/actions/go-setup-cache
with:
go-version-file: src/go.mod
Expand All @@ -55,7 +55,7 @@ jobs:
- uses: actions/checkout@v3

- name: Setup Golang with cache
if: needs.precheck.outputs.fileschanged == 'true'
if: needs.precheck.outputs.srcfileschanged == 'true'
uses: magnetikonline/action-golang-cache@v3
with:
go-version-file: src/go.mod
Expand All @@ -64,12 +64,12 @@ jobs:

# Install gotestfmt
- name: Set up gotestfmt
if: needs.precheck.outputs.fileschanged == 'true'
if: needs.precheck.outputs.srcfileschanged == 'true'
run: go install github.com/haveyoudebuggedit/gotestfmt/v2/cmd/gotestfmt@latest

# AWS creds
- name: Configure AWS credentials from Test account
if: needs.precheck.outputs.fileschanged == 'true'
if: needs.precheck.outputs.srcfileschanged == 'true'
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: arn:aws:iam::951767375776:role/corso-testing-role
Expand All @@ -78,7 +78,7 @@ jobs:

# run the tests
- name: Integration Tests
if: needs.precheck.outputs.fileschanged == 'true'
if: needs.precheck.outputs.srcfileschanged == 'true'
env:
CLIENT_ID: ${{ secrets.CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
Expand All @@ -95,7 +95,7 @@ jobs:

# Upload the original go test log as an artifact for later review.
- name: Upload test log
if: failure() && needs.precheck.outputs.fileschanged == 'true'
if: failure() && needs.precheck.outputs.srcfileschanged == 'true'
uses: actions/upload-artifact@v3
with:
name: test-log
Expand All @@ -118,13 +118,13 @@ jobs:
- uses: actions/checkout@v3

- name: Setup Golang with cache
if: needs.precheck.outputs.fileschanged == 'true'
if: needs.precheck.outputs.srcfileschanged == 'true'
uses: magnetikonline/action-golang-cache@v3
with:
go-version-file: src/go.mod

- name: Go Lint
if: needs.precheck.outputs.fileschanged == 'true'
if: needs.precheck.outputs.srcfileschanged == 'true'
uses: golangci/golangci-lint-action@v3
with:
version: v1.45.2
Expand All @@ -133,9 +133,9 @@ jobs:

# check licenses
- name: Get go-licenses
if: needs.precheck.outputs.fileschanged == 'true'
if: needs.precheck.outputs.srcfileschanged == 'true'
run: go install github.com/google/go-licenses@latest

- name: Run go-licenses
if: needs.precheck.outputs.fileschanged == 'true'
if: needs.precheck.outputs.srcfileschanged == 'true'
run: go-licenses check github.com/alcionai/corso/src --ignore github.com/alcionai/corso/src
58 changes: 0 additions & 58 deletions .github/workflows/docgen.yml

This file was deleted.

81 changes: 81 additions & 0 deletions .github/workflows/docs-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: CI Tests for docs
on:
push:
branches: [main]
pull_request:
branches: [main]

permissions:
# required to retrieve AWS credentials
id-token: write
contents: write
pull-requests: read

# cancel currently running jobs if a new version of the branch is pushed
concurrency:
group: docs-ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:

# ----------------------------------------------------------------------------------------------------
# --- Precheck ---------------------------------------------------------------------------------------
# ----------------------------------------------------------------------------------------------------
precheck:
uses: alcionai/corso/.github/workflows/_filechange_checker.yml@docs-ci # TODO: change this to main

# ----------------------------------------------------------------------------------------------------
# --- Generate cli docs ------------------------------------------------------------------------------
# ----------------------------------------------------------------------------------------------------

Generate-Markdown:
needs: precheck
if: needs.precheck.outputs.srcfileschanged == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.ref }}

- name: Setup Golang with cache
uses: magnetikonline/action-golang-cache@v3
with:
go-version-file: src/go.mod

# run the markdown generator
- name: Generate Markdown
working-directory: ./src
run: |
go run ./cmd/mdgen/mdgen.go generate

# migrate generated md files into /docs/docs/cli
- name: Move CLI .md to Docs
run: |
mkdir -p ./docs/docs/cli
mv ./src/cmd/mdgen/cli_markdown/* ./docs/docs/cli/
rm -R ./src/cmd/mdgen/cli_markdown/

# ----------------------------------------------------------------------------------------------------
# --- Docs Linting -----------------------------------------------------------------------------------
# ----------------------------------------------------------------------------------------------------

Docs-Linting:
needs: [precheck , Generate-Markdown]
environment: Testing
runs-on: ubuntu-latest
defaults:
run:
working-directory: docs
steps:
- uses: actions/checkout@v3

- name: Install dependencies for docs lint
if: needs.precheck.outputs.docfileschanged == 'true'
run: |
sudo snap install --edge vale
npm install -g markdownlint-cli

- name: Run docs lint
if: needs.precheck.outputs.docfileschanged == 'true'
run: |
make -o genclidocs check
2 changes: 1 addition & 1 deletion .github/workflows/image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

Per-SHA-Image:
needs: precheck
if: needs.precheck.outputs.fileschanged == 'true'
if: needs.precheck.outputs.srcfileschanged == 'true'
runs-on: ubuntu-latest
defaults:
run:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@
/docker/bin
/website/dist

*/test_results/**
*/test_results/**
docs/docs/cli
ryanfkeepers marked this conversation as resolved.
Show resolved Hide resolved
29 changes: 0 additions & 29 deletions docs/docs/cli/corso_backup_create_exchange.md

This file was deleted.

27 changes: 0 additions & 27 deletions docs/docs/cli/corso_backup_create_onedrive.md

This file was deleted.

27 changes: 0 additions & 27 deletions docs/docs/cli/corso_backup_delete_exchange.md

This file was deleted.

Loading