From 8ba48d22484911376cafbf7b6f298be47e68a8de Mon Sep 17 00:00:00 2001 From: Kaj Kowalski Date: Sat, 24 May 2025 21:45:08 +0200 Subject: [PATCH] Adds stale issue management and refines CI workflows Introduces a configuration file for automatic management of stale issues, allowing better maintenance of the repository. Refines continuous integration workflows to include dependency review and release processes directly within the CI pipeline, improving efficiency and reducing redundancy by combining previously separate workflows. Updates branches and tags trigger configuration for CI workflows to ensure consistency in branch protection and deployment practices. Ensures CodeQL analysis setup aligns with current repository language use to enhance security scanning procedures. --- .github/ISSUE_TEMPLATE/bug_report.yml | 2 +- .github/stale.yml | 67 +++++++++++++++ .github/workflows/ci.yml | 71 ++++++++++++++- .github/workflows/codeql.yml | 109 ++++++++++++++++++------ .github/workflows/dependency-review.yml | 22 ----- .github/workflows/release.yml | 47 ---------- .gitignore | 1 + README.md | 10 +-- main.go | 2 +- 9 files changed, 227 insertions(+), 104 deletions(-) create mode 100644 .github/stale.yml delete mode 100644 .github/workflows/dependency-review.yml delete mode 100644 .github/workflows/release.yml diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 0f92b70..5f760ab 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -29,7 +29,7 @@ body: value: | 1. 2. - 3. + 3. validations: required: true diff --git a/.github/stale.yml b/.github/stale.yml new file mode 100644 index 0000000..0025e04 --- /dev/null +++ b/.github/stale.yml @@ -0,0 +1,67 @@ +# Configuration for probot-stale - https://github.com/probot/stale + +# Number of days of inactivity before an issue becomes stale +daysUntilStale: 60 + +# Number of days of inactivity before a stale issue is closed +daysUntilClose: 14 + +# Issues with these labels will never be considered stale +exemptLabels: + - pinned + - security + - bug + - enhancement + - documentation + - "in progress" + +# Label to use when marking an issue as stale +staleLabel: stale + +# Comment to post when marking an issue as stale +markComment: > + This issue has been automatically marked as stale because it has not had + recent activity. It will be closed in 14 days if no further activity occurs. + Thank you for your contributions to Articulate Rise Parser! + +# Comment to post when closing a stale issue +closeComment: > + This issue has been automatically closed due to inactivity. + Feel free to reopen if this is still relevant. + +# Limit to only specific repos (optional) +# only: +# - repo1 +# - repo2 + +# Limit the number of actions per hour, from 1-30. Default is 30 +limitPerRun: 30 + +# Set to true to ignore issues in a project (defaults to false) +exemptProjects: false + +# Set to true to ignore issues in a milestone (defaults to false) +exemptMilestones: true + +# Set to true to ignore issues with an assignee (defaults to false) +exemptAssignees: true + +# Label to use when marking a pull request as stale +stalePrLabel: stale-pr + +# Comment to post when marking a pull request as stale +markPrComment: > + This pull request has been automatically marked as stale because it has not had + recent activity. It will be closed in 14 days if no further activity occurs. + Thank you for your contributions to Articulate Rise Parser! + +# Comment to post when closing a stale pull request +closePrComment: > + This pull request has been automatically closed due to inactivity. + Feel free to reopen if you want to continue working on this. + +# Limit to only `issues` or `pulls` (optional) +# only: issues + +# Set to true to ignore PRs with the WIP label or title prefix (defaults to false) +exemptWIP: true diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 332ba65..fa17bed 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,12 +2,15 @@ name: CI on: push: - branches: [master, develop] + branches: [ "master", "develop" ] + tags: + - "v*.*.*" pull_request: - branches: [master, develop] + branches: [ "master", "develop" ] jobs: test: + name: Test runs-on: ubuntu-latest strategy: matrix: @@ -49,11 +52,73 @@ jobs: - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v5 with: - token: ${{ secrets.CODECOV_TOKEN }} + flags: Go ${{ matrix.go }} slug: kjanat/articulate-parser + token: ${{ secrets.CODECOV_TOKEN }} - name: Upload test results to Codecov if: ${{ !cancelled() }} uses: codecov/test-results-action@v1 with: + flags: Go ${{ matrix.go }} token: ${{ secrets.CODECOV_TOKEN }} + + dependency-review: + name: Dependency Review + runs-on: ubuntu-latest + permissions: + contents: read + if: github.event_name == 'pull_request' + steps: + - name: 'Checkout Repository' + uses: actions/checkout@v4 + + - name: 'Dependency Review' + uses: actions/dependency-review-action@v4 + with: + fail-on-severity: moderate + comment-summary-in-pr: always + + # # Use comma-separated names to pass list arguments: + # deny-licenses: LGPL-2.0, BSD-2-Clause + + release: + name: Release + runs-on: ubuntu-latest + if: github.ref_type == 'tag' + permissions: + contents: write + needs: [ "test" ] + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + check-latest: true + + - name: Run tests + run: go test -v ./... + + - name: Build binaries + run: | + # Build for different platforms + OS = ["darwin", "freebsd", "linux", "windows"] + ARCH = ["amd64", "arm64"] + + for os in OS: + for arch in ARCH: + GOOS=$os GOARCH=$arch go build -o articulate-parser-$os-$arch main.go + + - name: Create Release + uses: softprops/action-gh-release@v2 + with: + files: articulate-parser-* + generate_release_notes: true + draft: false + prerelease: ${{ startsWith(github.ref, 'refs/tags/v0.') }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 895a198..5d96a02 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -1,41 +1,100 @@ -name: CodeQL +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" on: - workflow_call: - # push: - # branches: [master, develop] - # pull_request: - # branches: [master] - # schedule: - # - cron: '30 1 * * 0' + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + schedule: + - cron: '44 16 * * 6' jobs: analyze: - name: Analyze - runs-on: ubuntu-latest + name: Analyze (${{ matrix.language }}) + # Runner size impacts CodeQL analysis time. To learn more, please see: + # - https://gh.io/recommended-hardware-resources-for-running-codeql + # - https://gh.io/supported-runners-and-hardware-resources + # - https://gh.io/using-larger-runners (GitHub.com only) + # Consider using larger runners or machines with greater resources for possible analysis time improvements. + runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }} permissions: + # required for all workflows + security-events: write + + # required to fetch internal or private CodeQL packs + packages: read + + # only required for workflows in private repositories actions: read contents: read - security-events: write strategy: fail-fast: false matrix: - language: ['go'] - + include: + - language: actions + build-mode: none + - language: go + build-mode: autobuild + # CodeQL supports the following values keywords for 'language': 'actions', 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' + # Use `c-cpp` to analyze code written in C, C++ or both + # Use 'java-kotlin' to analyze code written in Java, Kotlin or both + # Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both + # To learn more about changing the languages that are analyzed or customizing the build mode for your analysis, + # see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning. + # If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how + # your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages steps: - - name: Checkout repository - uses: actions/checkout@v4 + - name: Checkout repository + uses: actions/checkout@v4 - - name: Initialize CodeQL - uses: github/codeql-action/init@v3 - with: - languages: ${{ matrix.language }} + # Add any setup steps before running the `github/codeql-action/init` action. + # This includes steps like installing compilers or runtimes (`actions/setup-node` + # or others). This is typically only required for manual builds. + # - name: Setup runtime (example) + # uses: actions/setup-example@v1 - - name: Autobuild - uses: github/codeql-action/autobuild@v3 + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v3 + with: + languages: ${{ matrix.language }} + build-mode: ${{ matrix.build-mode }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v3 - with: - category: '/language:${{matrix.language}}' + # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality + + # If the analyze step fails for one of the languages you are analyzing with + # "We were unable to automatically build your code", modify the matrix above + # to set the build mode to "manual" for that language. Then modify this step + # to build your code. + # â„šī¸ Command-line programs to run using the OS shell. + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + - if: matrix.build-mode == 'manual' + shell: bash + run: | + echo 'If you are using a "manual" build mode for one or more of the' \ + 'languages you are analyzing, replace this with the commands to build' \ + 'your code, for example:' + echo ' make bootstrap' + echo ' make release' + exit 1 + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v3 + with: + category: "/language:${{matrix.language}}" diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml deleted file mode 100644 index d24308a..0000000 --- a/.github/workflows/dependency-review.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: Dependency Review - -on: [workflow_call] # [pull_request] - -permissions: - contents: read - -jobs: - dependency-review: - runs-on: ubuntu-latest - steps: - - name: 'Checkout Repository' - uses: actions/checkout@v4 - - - name: 'Dependency Review' - uses: actions/dependency-review-action@v4 - with: - fail-on-severity: moderate - comment-summary-in-pr: always - - # # Use comma-separated names to pass list arguments: - # deny-licenses: LGPL-2.0, BSD-2-Clause diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 31c4ecf..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,47 +0,0 @@ -name: Release - -on: - push: - tags: - - 'v*' - -permissions: - contents: write - -jobs: - release: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: 1.21.x - - - name: Run tests - run: go test -v ./... - - - name: Build binaries - run: | - # Build for different platforms - GOOS=windows GOARCH=amd64 go build -o articulate-parser-windows-amd64.exe main.go - GOOS=linux GOARCH=amd64 go build -o articulate-parser-linux-amd64 main.go - GOOS=darwin GOARCH=amd64 go build -o articulate-parser-darwin-amd64 main.go - GOOS=darwin GOARCH=arm64 go build -o articulate-parser-darwin-arm64 main.go - - - name: Create Release - uses: softprops/action-gh-release@v1 - with: - files: | - articulate-parser-windows-amd64.exe - articulate-parser-linux-amd64 - articulate-parser-darwin-amd64 - articulate-parser-darwin-arm64 - generate_release_notes: true - draft: false - prerelease: ${{ startsWith(github.ref, 'refs/tags/v0.') }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index e5cd41c..c1f20e8 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,4 @@ go.work # Local test files output/ articulate-sample.json +test-output.* diff --git a/README.md b/README.md index 4c3aa50..f9c0b7c 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,8 @@ A Go-based parser that converts Articulate Rise e-learning content to various formats including Markdown and Word documents. [![Go version](https://img.shields.io/github/go-mod/go-version/kjanat/articulate-parser?logo=Go&logoColor=white)][gomod] - - +[![Go Doc](https://godoc.org/github.com/kjanat/articulate-parser?status.svg)][Package documentation] +[![Go Report Card](https://goreportcard.com/badge/github.com/kjanat/articulate-parser)][Go report] [![Tag](https://img.shields.io/github/v/tag/kjanat/articulate-parser?sort=semver&label=Tag)][Tags] [![Release Date](https://img.shields.io/github/release-date/kjanat/articulate-parser?label=Release%20date)][Latest release] [![License](https://img.shields.io/github/license/kjanat/articulate-parser?label=License)](LICENSE) @@ -63,7 +63,7 @@ go run main.go [output_path] 1. **Parse from URL and export to Markdown:** ```bash -go run main.go "https://rise.articulate.com/share/rcIndCUPTdBfKAShckA5XSz3YSHpi5al#/" md +go run main.go "https://rise.articulate.com/share/N_APNg40Vr2CSH2xNz-ZLATM5kNviDIO#/" md ``` 2. **Parse from local file and export to Word:** @@ -139,8 +139,8 @@ The parser works with the standard Articulate Rise JSON format which includes: The parser automatically extracts share IDs from Articulate Rise URLs: -- Input: `https://rise.articulate.com/share/rcIndCUPTdBfKAShckA5XSz3YSHpi5al#/` -- API URL: `https://rise.articulate.com/api/rise-runtime/boot/share/rcIndCUPTdBfKAShckA5XSz3YSHpi5al` +- Input: `https://rise.articulate.com/share/N_APNg40Vr2CSH2xNz-ZLATM5kNviDIO#/` +- API URL: `https://rise.articulate.com/api/rise-runtime/boot/share/N_APNg40Vr2CSH2xNz-ZLATM5kNviDIO` ## Error Handling diff --git a/main.go b/main.go index e09ad38..833a0bd 100644 --- a/main.go +++ b/main.go @@ -138,7 +138,7 @@ func NewArticulateParser() *ArticulateParser { } func (p *ArticulateParser) ExtractShareID(uri string) (string, error) { - // Extract share ID from URI like: https://rise.articulate.com/share/rcIndCUPTdBfKAShckA5XSz3YSHpi5al#/ + // Extract share ID from URI like: https://rise.articulate.com/share/N_APNg40Vr2CSH2xNz-ZLATM5kNviDIO#/ re := regexp.MustCompile(`/share/([a-zA-Z0-9_-]+)`) matches := re.FindStringSubmatch(uri) if len(matches) < 2 {