-
Notifications
You must be signed in to change notification settings - Fork 20
chore: refactoring and cleaning up the code to adhere to standards #105
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
Changes from all commits
34242da
8791a71
87697b9
f14cc8d
fd9e21e
067a089
3dca833
6f3ea1e
7894c5f
a339308
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,196 @@ | ||||||
| name: CI | ||||||
|
|
||||||
| on: | ||||||
| push: | ||||||
| branches: [ main, develop ] | ||||||
| pull_request: | ||||||
| branches: [ main, develop ] | ||||||
|
|
||||||
| jobs: | ||||||
| test: | ||||||
| runs-on: ubuntu-latest | ||||||
|
|
||||||
| steps: | ||||||
| - name: Checkout code | ||||||
| uses: actions/checkout@v4 | ||||||
|
|
||||||
| - name: Set up Go | ||||||
| uses: actions/setup-go@v4 | ||||||
| with: | ||||||
| go-version: '1.22' | ||||||
|
|
||||||
| - name: Cache Go modules | ||||||
| uses: actions/cache@v3 | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update to cache@v4. The Apply this diff: - uses: actions/cache@v3
+ uses: actions/cache@v4Based on static analysis hints. 📝 Committable suggestion
Suggested change
🧰 Tools🪛 actionlint (1.7.7)23-23: the runner of "actions/cache@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue (action) 🤖 Prompt for AI Agents |
||||||
| with: | ||||||
| path: ~/go/pkg/mod | ||||||
| key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||||||
| restore-keys: | | ||||||
| ${{ runner.os }}-go- | ||||||
|
|
||||||
| - name: Install dependencies | ||||||
| run: go mod download | ||||||
|
|
||||||
| - name: Run go vet | ||||||
| run: go vet ./... | ||||||
|
|
||||||
| - name: Check formatting | ||||||
| run: | | ||||||
| if [ "$(gofmt -l .)" != "" ]; then | ||||||
| echo "Code is not formatted. Run 'go fmt ./...' to fix." | ||||||
| gofmt -l . | ||||||
| exit 1 | ||||||
| fi | ||||||
|
|
||||||
| - name: Build application | ||||||
| run: | | ||||||
| go build -o bin/golearn ./cmd/golearn | ||||||
| chmod +x bin/golearn | ||||||
|
|
||||||
| - name: Test build works | ||||||
| run: | | ||||||
| ./bin/golearn --help | ||||||
| ./bin/golearn help | ||||||
|
|
||||||
| - name: Test list command | ||||||
| run: | | ||||||
| ./bin/golearn list | ||||||
|
|
||||||
| - name: Test progress command | ||||||
| run: | | ||||||
| ./bin/golearn progress | ||||||
|
|
||||||
| - name: Test hint command (with valid exercise) | ||||||
| run: | | ||||||
| ./bin/golearn hint 01_hello || true | ||||||
|
|
||||||
| - name: Test solution command (with valid exercise) | ||||||
| run: | | ||||||
| echo "n" | ./bin/golearn solution 01_hello | ||||||
|
|
||||||
| - name: Test verify command (templates should fail) | ||||||
| run: | | ||||||
| echo "Testing that template exercises fail as expected..." | ||||||
| if ./bin/golearn verify; then | ||||||
| echo "FAILURE: Template exercises should fail but they passed - this indicates templates are complete when they should be incomplete for students to fill in" | ||||||
| exit 1 | ||||||
| else | ||||||
| echo "SUCCESS: Template exercises failed as expected - templates are properly incomplete for student learning" | ||||||
| fi | ||||||
|
|
||||||
| - name: Test verify command with solutions (should pass) | ||||||
| run: | | ||||||
| echo "Testing that solution exercises pass..." | ||||||
| # Test a few key exercises with their solutions | ||||||
| ./bin/golearn verify 01_hello --solution | ||||||
| ./bin/golearn verify 36_json --solution | ||||||
| ./bin/golearn verify 37_xml --solution | ||||||
|
|
||||||
| - name: Test specific template exercises (should fail) | ||||||
| run: | | ||||||
| echo "Testing that specific template exercises fail as expected..." | ||||||
| failed_templates=() | ||||||
|
|
||||||
| # Test a few key template exercises to ensure they fail | ||||||
| for exercise in 01_hello 02_values 36_json 37_xml; do | ||||||
| echo "Testing template exercise: $exercise" | ||||||
| if ./bin/golearn verify "$exercise"; then | ||||||
| echo "ERROR: Template $exercise should fail but passed - this template is complete when it should be incomplete for students to learn from" | ||||||
| failed_templates+=("$exercise") | ||||||
| else | ||||||
| echo "SUCCESS: Template $exercise failed as expected - template is properly incomplete for student learning" | ||||||
| fi | ||||||
| done | ||||||
|
|
||||||
| # Report results | ||||||
| if [ ${#failed_templates[@]} -eq 0 ]; then | ||||||
| echo "SUCCESS: All tested template exercises failed as expected - templates are properly incomplete for student learning" | ||||||
| else | ||||||
| echo "FAILURE: The following template exercises should have failed but passed - these templates are complete when they should be incomplete:" | ||||||
| for exercise in "${failed_templates[@]}"; do | ||||||
| echo " - $exercise" | ||||||
| done | ||||||
| exit 1 | ||||||
| fi | ||||||
|
|
||||||
| - name: Test reset command | ||||||
| run: | | ||||||
| ./bin/golearn reset 01_hello | ||||||
|
|
||||||
| - name: Test init command (built-in templates) | ||||||
| run: | | ||||||
| ./bin/golearn init | ||||||
|
|
||||||
| - name: Test error handling | ||||||
| run: | | ||||||
| # Test invalid commands | ||||||
| ./bin/golearn invalid-command || true | ||||||
| ./bin/golearn hint || true | ||||||
| ./bin/golearn solution || true | ||||||
| ./bin/golearn reset || true | ||||||
|
|
||||||
| - name: Test theme options | ||||||
| run: | | ||||||
| ./bin/golearn --no-color list | ||||||
| ./bin/golearn --theme=high-contrast list | ||||||
| ./bin/golearn --theme=monochrome list | ||||||
|
|
||||||
| - name: Test publish dry-run | ||||||
| run: | | ||||||
| ./bin/golearn publish --dry-run | ||||||
|
|
||||||
| - name: Run exercise tests | ||||||
| run: | | ||||||
| echo "Running go tests for non-template exercise packages..." | ||||||
| packages=$(go list ./internal/exercises/... | grep -v '/templates') | ||||||
| if [ -n "$packages" ]; then | ||||||
| go test $packages | ||||||
| else | ||||||
| echo "No non-template packages to test." | ||||||
| fi | ||||||
|
|
||||||
| - name: Test ALL exercise solutions (comprehensive) | ||||||
| run: | | ||||||
| echo "Testing ALL solution exercises to ensure they pass..." | ||||||
| failed_exercises=() | ||||||
|
|
||||||
| echo "Discovering exercises that actually have solution implementations..." | ||||||
| exercises_to_test=() | ||||||
| for dir in ./internal/exercises/solutions/*; do | ||||||
| [ -d "$dir" ] || continue | ||||||
| if ls "$dir"/*.go >/dev/null 2>&1; then | ||||||
| exercises_to_test+=("$(basename "$dir")") | ||||||
| fi | ||||||
| done | ||||||
|
|
||||||
| if [ ${#exercises_to_test[@]} -eq 0 ]; then | ||||||
| echo "No solution exercises found to test. Skipping." | ||||||
| else | ||||||
| for exercise in "${exercises_to_test[@]}"; do | ||||||
| echo "Testing solution exercise: $exercise" | ||||||
| if ./bin/golearn verify "$exercise" --solution; then | ||||||
| echo "PASS: $exercise" | ||||||
| else | ||||||
| echo "FAIL: $exercise - solution implementation is broken or incomplete" | ||||||
| failed_exercises+=("$exercise") | ||||||
| fi | ||||||
| done | ||||||
|
|
||||||
| if [ ${#failed_exercises[@]} -eq 0 ]; then | ||||||
| echo "SUCCESS: All solution exercises passed - all solutions are working correctly" | ||||||
| else | ||||||
| echo "FAILURE: The following solution exercises failed - these solutions need to be fixed:" | ||||||
| for exercise in "${failed_exercises[@]}"; do | ||||||
| echo " - $exercise" | ||||||
| done | ||||||
| exit 1 | ||||||
| fi | ||||||
| fi | ||||||
|
|
||||||
| - name: Verify binary works in different directory | ||||||
| run: | | ||||||
| cd /tmp | ||||||
| $GITHUB_WORKSPACE/bin/golearn --help | ||||||
|
|
||||||
| - name: Test watch command (timeout after 5 seconds) | ||||||
| run: | | ||||||
| timeout 5s ./bin/golearn watch || true | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| name: Deploy Jekyll site to Pages | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ main ] | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
| pages: write | ||
| id-token: write | ||
|
|
||
| concurrency: | ||
| group: "pages" | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Ruby | ||
| uses: ruby/setup-ruby@v1 | ||
| with: | ||
| ruby-version: '3.1' | ||
| bundler-cache: true | ||
|
|
||
| - name: Setup Pages | ||
| uses: actions/configure-pages@v4 | ||
|
|
||
| - name: Build with Jekyll | ||
| run: | | ||
| cd docs | ||
| bundle install --path vendor/bundle | ||
| bundle exec jekyll build | ||
| env: | ||
| JEKYLL_ENV: production | ||
|
|
||
| - name: Upload artifact | ||
| uses: actions/upload-pages-artifact@v3 | ||
| with: | ||
| path: ./docs/_site | ||
|
|
||
| deploy: | ||
| environment: | ||
| name: github-pages | ||
| url: ${{ steps.deployment.outputs.page_url }} | ||
| runs-on: ubuntu-latest | ||
| needs: build | ||
| steps: | ||
| - name: Deploy to GitHub Pages | ||
| id: deployment | ||
| uses: actions/deploy-pages@v4 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| source "https://rubygems.org" | ||
|
|
||
| gem "jekyll", "~> 4.3" | ||
| gem "minima", "~> 2.5" | ||
|
|
||
| group :jekyll_plugins do | ||
| gem "jekyll-feed", "~> 0.12" | ||
| gem "jekyll-sitemap" | ||
| gem "jekyll-seo-tag" | ||
| end | ||
|
|
||
| # Windows and JRuby does not include zoneinfo files, so bundle the tzinfo-data gem | ||
| # and associated library. | ||
| platforms :mingw, :x64_mingw, :mswin, :jruby do | ||
| gem "tzinfo", ">= 1", "< 3" | ||
| gem "tzinfo-data" | ||
| end | ||
|
|
||
| # Performance-booster for watching directories on Windows | ||
| gem "wdm", "~> 0.1.1", :platforms => [:mingw, :x64_mingw, :mswin] | ||
|
|
||
| # Lock `http_parser.rb` gem to `v0.6.x` on JRuby builds since newer versions of the gem | ||
| # do not have a Java counterpart. | ||
| gem "http_parser.rb", "~> 0.6.0", :platforms => [:jruby] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| # GoLearn Documentation | ||
|
|
||
| This directory contains the Jekyll-based documentation website for GoLearn. | ||
|
|
||
| ## Local Development | ||
|
|
||
| To run the documentation site locally: | ||
|
|
||
| 1. Install Ruby and Bundler | ||
| 2. Install dependencies: | ||
| ```bash | ||
| cd docs | ||
| bundle install | ||
| ``` | ||
| 3. Start the Jekyll server: | ||
| ```bash | ||
| bundle exec jekyll serve | ||
| ``` | ||
| 4. Open http://localhost:4000 in your browser | ||
|
|
||
| ## Deployment | ||
|
|
||
| The site is automatically deployed to GitHub Pages when changes are pushed to the main branch. | ||
|
|
||
| ## Structure | ||
|
|
||
| - `_config.yml` - Jekyll configuration | ||
| - `_layouts/` - HTML templates | ||
| - `_includes/` - Reusable components | ||
| - `assets/` - CSS, JS, and other assets | ||
| - `*.md` - Markdown pages | ||
|
|
||
| ## Theme | ||
|
|
||
| The site uses a custom gopher-themed design with: | ||
| - Playful gopher animations | ||
| - Go-inspired color scheme | ||
| - Responsive design | ||
| - Clean, readable typography |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| # GoLearn Documentation Site | ||
| # A fun, gopher-themed Jekyll site for Go learning | ||
|
|
||
| title: GoLearn | ||
| description: "Learn Go the fun way! A Rustlings-style interactive Go tutorial with gopher-powered exercises." | ||
| author: "GoLearn Team" | ||
| email: "golearn@example.com" | ||
| url: "https://golearn.dev" | ||
| baseurl: "" | ||
|
|
||
| # Jekyll configuration | ||
| markdown: kramdown | ||
| highlighter: rouge | ||
| theme: minima | ||
| plugins: | ||
| - jekyll-feed | ||
| - jekyll-sitemap | ||
| - jekyll-seo-tag | ||
|
|
||
| # Site settings | ||
| exclude: | ||
| - Gemfile | ||
| - Gemfile.lock | ||
| - README.md | ||
| - vendor/ | ||
|
|
||
| # Collections | ||
| collections: | ||
| exercises: | ||
| output: true | ||
| permalink: /:name/ | ||
|
|
||
| # Default layouts | ||
| defaults: | ||
| - scope: | ||
| path: "" | ||
| type: "pages" | ||
| values: | ||
| layout: "default" | ||
| - scope: | ||
| path: "" | ||
| type: "exercises" | ||
| values: | ||
| layout: "exercise" | ||
|
|
||
| # Navigation | ||
| header_pages: | ||
| - index.md | ||
| - getting-started.md | ||
| - exercises.md | ||
| - contributing.md | ||
| - about.md | ||
|
|
||
| # Gopher theme settings | ||
| gopher_theme: | ||
| primary_color: "#00ADD8" # Go blue | ||
| secondary_color: "#5DC9E2" # Light blue | ||
| accent_color: "#FF6B6B" # Fun red | ||
| text_color: "#2D3748" # Dark gray | ||
| background_color: "#F7FAFC" # Light gray | ||
|
|
||
| # Social links (optional) | ||
| social: | ||
| github: "your-username/golearn" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix the GitHub repo slug so generated links work. Everything that pulls -social:
- github: "your-username/golearn"
+social:
+ github: "zhravan/golearn"🤖 Prompt for AI Agents |
||
| twitter: "golearn_dev" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update to setup-go@v5.
The
actions/setup-go@v4runner is deprecated and too old for GitHub Actions.Apply this diff:
Based on static analysis hints.
📝 Committable suggestion
🧰 Tools
🪛 actionlint (1.7.7)
18-18: the runner of "actions/setup-go@v4" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
🤖 Prompt for AI Agents