-
-
Notifications
You must be signed in to change notification settings - Fork 0
feat: first version #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
6a2f3c2
feat: first version
christiangda d89ff86
fix: github workflows and files
christiangda cf733e7
feat: update the go version
christiangda baa5bfb
fix: install scc tools from binary
christiangda b3ca029
fix: install scc tools from binary
christiangda c430513
fix: install scc tools from binary
christiangda 88b42f3
fix: install scc tools from binary
christiangda a47d1cf
fix: install scc tools from binary
christiangda 7a01913
fix: workflows steps name
christiangda File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # These are supported funding model platforms | ||
| github: [christiangda] | ||
| liberapay: christiangda | ||
| patreon: christiangda | ||
| custom: ["https://paypal.me/slashdevops"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| name: CodeQL config | ||
| # queries: | ||
| # - name: Run custom queries | ||
| # uses: ./queries | ||
| # # Run all extra query suites, both because we want to | ||
| # # and because it'll act as extra testing. This is why | ||
| # # we include both even though one is a superset of the | ||
| # # other, because we're testing the parsing logic and | ||
| # # that the suites exist in the codeql bundle. | ||
| # - uses: security-extended | ||
| # - uses: security-and-quality | ||
| paths-ignore: | ||
| - mocks |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| # Development Guidelines | ||
|
|
||
| This document contains the critical information about working with the project codebase. | ||
| Follows these guidelines precisely to ensure consistency and maintainability of the code. | ||
|
|
||
| ## Stack | ||
|
|
||
| - Language: Go (Go 1.22+) | ||
| - Framework: Go standard library | ||
| - Testing: Go's built-in testing package | ||
| - Dependency Management: Go modules | ||
| - Version Control: Git | ||
| - Documentation: go doc | ||
| - Code Review: Pull requests on GitHub | ||
| - CI/CD: GitHub Actions | ||
| - Logging: `slog` package from the standard library | ||
|
|
||
| ## Project Structure | ||
|
|
||
| Since this is a library build in native go, the files are mostly organized following the standard Go project layout with some additional folders for specific functionalities. | ||
|
|
||
| - Library files are located in the root directory. | ||
| - examples/ contains example code demonstrating how to use the library. | ||
| - .github/ contains GitHub-specific files such as workflows for CI/CD. | ||
| - .gitignore specifies files and directories to be ignored by Git. | ||
| - .vscode/ contains Visual Studio Code configuration files. | ||
| - LICENSE is the license file for the project. | ||
| - README.md provides an overview of the project, installation instructions, usage examples, and other relevant information. | ||
| - go.mod and go.sum manage the project's dependencies. | ||
| - \*.go files contain the main source code of the library. | ||
| - \*\_test.go files contain the test cases for the library. | ||
|
|
||
| ## Code Style | ||
|
|
||
| - Follow Go's idiomatic style defined in | ||
| - #fetch https://google.github.io/styleguide/go/guide | ||
| - #fetch https://google.github.io/styleguide/go/decisions | ||
| - #fetch https://google.github.io/styleguide/go/best-practices | ||
| - #fetch https://golang.org/doc/effective_go.html | ||
| - Use meaningful names for variables, functions, and packages. | ||
| - Keep functions small and focused on a single task. | ||
| - Use comments to explain complex logic or decisions. | ||
| - Use dependency injection for services and repositories to facilitate testing and maintainability. | ||
| - don't use `interface{}` instead use `any` for better readability. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # To get started with Dependabot version updates, you'll need to specify which | ||
| # package ecosystems to update and where the package manifests are located. | ||
| # Please see the documentation for all configuration options: | ||
| # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates | ||
|
|
||
| version: 2 | ||
| updates: | ||
| - package-ecosystem: "gomod" # See documentation for possible values | ||
| directory: "/" # Location of package manifests | ||
| schedule: | ||
| interval: "weekly" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| --- | ||
| # https://docs.github.com/es/repositories/releasing-projects-on-github/automatically-generated-release-notes | ||
| changelog: | ||
| categories: | ||
| - title: Breaking Changes 🛠 | ||
| labels: | ||
| - Semver-Major | ||
| - breaking-change | ||
| - title: New Features 🎉 | ||
| labels: | ||
| - Semver-Minor | ||
| - enhancement | ||
| - title: Other Changes | ||
| labels: | ||
| - "*" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| # 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 Advanced" | ||
|
|
||
| on: | ||
| push: | ||
| branches: ["main"] | ||
| pull_request: | ||
| branches: ["main"] | ||
| schedule: | ||
| - cron: "10 12 * * 3" | ||
|
|
||
| jobs: | ||
| analyze: | ||
| 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 | ||
|
|
||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| 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@v6 | ||
|
|
||
| # 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 | ||
|
|
||
| # Initializes the CodeQL tools for scanning. | ||
| - name: Initialize CodeQL | ||
| uses: github/codeql-action/init@v4 | ||
| 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. | ||
|
|
||
| # 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@v4 | ||
| with: | ||
| category: "/language:${{matrix.language}}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| name: Main | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v6 | ||
|
|
||
| - name: Set up Go | ||
| uses: actions/setup-go@v6 | ||
| with: | ||
| go-version-file: ./go.mod | ||
|
|
||
| - name: Summary Information | ||
| run: | | ||
| echo "# Push Summary" > $GITHUB_STEP_SUMMARY | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
| echo "**Repository:** ${{ github.repository }}" >> $GITHUB_STEP_SUMMARY | ||
| echo "**Push:** ${{ github.event.head_commit.message }}" >> $GITHUB_STEP_SUMMARY | ||
| echo "**Author:** ${{ github.event.head_commit.author.name }}" >> $GITHUB_STEP_SUMMARY | ||
| echo "**Branch:** ${{ github.ref }}" >> $GITHUB_STEP_SUMMARY | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
|
|
||
| - name: Tools and versions | ||
| run: | | ||
| echo "## Tools and versions" >> $GITHUB_STEP_SUMMARY | ||
|
|
||
| ubuntu_version=$(lsb_release -a 2>&1 | grep "Description" | awk '{print $2, $3, $4}') | ||
| echo "Ubuntu version: $ubuntu_version" | ||
| echo "**Ubuntu Version:** $ubuntu_version" >> $GITHUB_STEP_SUMMARY | ||
|
|
||
| bash_version=$(bash --version | head -n 1 | awk '{print $4}') | ||
| echo "Bash version: $bash_version" | ||
| echo "**Bash Version:** $bash_version" >> $GITHUB_STEP_SUMMARY | ||
|
|
||
| git_version=$(git --version | awk '{print $3}') | ||
| echo "Git version: $git_version" | ||
| echo "**Git Version:** $git_version" >> $GITHUB_STEP_SUMMARY | ||
|
|
||
| go_version=$(go version | awk '{print $3}') | ||
| echo "Go version: $go_version" | ||
| echo "**Go Version:** $go_version" >> $GITHUB_STEP_SUMMARY | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
|
|
||
| - name: Lines of code | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| run: | | ||
| export TOOL_NAME="scc" | ||
| export GIT_ORG="boyter" | ||
| export GIT_REPO="scc" | ||
| export OS=$(uname -s) | ||
| export OS_ARCH=$(uname -m) | ||
| # Normalize architecture names to match asset naming | ||
| [[ "$OS_ARCH" == "aarch64" ]] && OS_ARCH="arm64" | ||
| [[ "$OS_ARCH" == "x86_64" ]] && OS_ARCH="x86_64" | ||
| export ASSETS_NAME=$(gh release view --repo ${GIT_ORG}/${GIT_REPO} --json assets -q "[.assets[] | select(.name | contains(\"${TOOL_NAME}\") and contains(\"${OS}\") and contains(\"${OS_ARCH}\"))] | sort_by(.createdAt) | last.name") | ||
|
|
||
| gh release download --repo $GIT_ORG/$GIT_REPO --pattern $ASSETS_NAME | ||
|
|
||
| # Extract based on file extension | ||
| if [[ "$ASSETS_NAME" == *.tar.gz ]]; then | ||
| tar -xzf $ASSETS_NAME | ||
| elif [[ "$ASSETS_NAME" == *.zip ]]; then | ||
| unzip $ASSETS_NAME | ||
| fi | ||
|
|
||
| rm $ASSETS_NAME | ||
|
|
||
| mv $TOOL_NAME ~/go/bin/$TOOL_NAME | ||
| ~/go/bin/$TOOL_NAME --version | ||
|
|
||
| # go install github.com/boyter/scc/v3@latest | ||
|
|
||
| scc --format html-table . | tee -a $GITHUB_STEP_SUMMARY | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
|
|
||
| - name: Test | ||
| run: | | ||
| echo "### Test report" >> $GITHUB_STEP_SUMMARY | ||
|
|
||
| go test -race -coverprofile=coverage.txt -covermode=atomic -tags=unit ./... | tee -a $GITHUB_STEP_SUMMARY | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
|
|
||
| - name: Test coverage | ||
| run: | | ||
| echo "## Test Coverage" >> $GITHUB_STEP_SUMMARY | ||
|
|
||
| # Generate coverage report using standard library tools | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
| echo "### Coverage report" >> $GITHUB_STEP_SUMMARY | ||
| echo '```' >> $GITHUB_STEP_SUMMARY | ||
| go tool cover -func=coverage.txt | tee -a $GITHUB_STEP_SUMMARY | ||
| echo '```' >> $GITHUB_STEP_SUMMARY | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
|
|
||
| # Calculate total coverage percentage | ||
| total_coverage=$(go tool cover -func=coverage.txt | grep total | awk '{print $3}') | ||
| echo "**Total Coverage:** $total_coverage" >> $GITHUB_STEP_SUMMARY | ||
|
|
||
| - name: Build | ||
| run: | | ||
| echo "## Build" >> $GITHUB_STEP_SUMMARY | ||
|
|
||
| go build ./... | tee -a $GITHUB_STEP_SUMMARY | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
| echo "Build completed successfully." >> $GITHUB_STEP_SUMMARY | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium
Copilot Autofix
AI 19 days ago
To fix the problem, explicitly declare minimal
GITHUB_TOKENpermissions in the workflow so the job does not inherit overly broad defaults. Since this workflow only needs to read repository contents and releases and write to the job summary (which does not require any special token permission), we can safely setcontents: readat the workflow level.The best fix is to add a
permissionsblock near the top of.github/workflows/main.yml, alongsidenameandon, so it applies to all jobs. Concretely, insert:between the
name: Mainandon:lines. No changes are needed to any steps, environment variables, or uses ofgithub.token. This restricts theGITHUB_TOKENto read-only access to repository contents while preserving all existing functionality (checkout, viewing and downloading releases, and generating summaries).