Skip to content
Merged
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
196 changes: 196 additions & 0 deletions .github/workflows/ci.yml
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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Update to setup-go@v5.

The actions/setup-go@v4 runner is deprecated and too old for GitHub Actions.

Apply this diff:

-      uses: actions/setup-go@v4
+      uses: actions/setup-go@v5

Based on static analysis hints.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
uses: actions/setup-go@v4
uses: actions/setup-go@v5
🧰 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
.github/workflows/ci.yml around line 18: the workflow uses the deprecated
actions/setup-go@v4; update the action reference to actions/setup-go@v5 by
replacing the uses line so the workflow runs the supported v5 runner (ensure any
v4-specific inputs are compatible with v5 and adjust inputs if needed).

with:
go-version: '1.22'

- name: Cache Go modules
uses: actions/cache@v3

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Update to cache@v4.

The actions/cache@v3 runner is deprecated and too old for GitHub Actions.

Apply this diff:

-      uses: actions/cache@v3
+      uses: actions/cache@v4

Based on static analysis hints.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
uses: actions/cache@v3
uses: actions/cache@v4
🧰 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
In .github/workflows/ci.yml around line 23, the workflow references the
deprecated actions/cache@v3; update that step to use actions/cache@v4 by
changing the uses entry to actions/cache@v4 (no other semantic changes
expected), then run a quick workflow lint or push to a branch to verify the
workflow runs correctly in CI.

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
55 changes: 55 additions & 0 deletions .github/workflows/pages.yml
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
24 changes: 24 additions & 0 deletions docs/Gemfile
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]
39 changes: 39 additions & 0 deletions docs/README.md
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
65 changes: 65 additions & 0 deletions docs/_config.yml
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"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Fix the GitHub repo slug so generated links work.

Everything that pulls site.social.github (e.g., the “View Template/Solution” buttons in the exercise layout and the footer link) points to https://github.com/your-username/golearn, which 404s. Please replace this placeholder with the actual repository slug (e.g., zhravan/golearn) so published docs link to the right code.

-social:
-  github: "your-username/golearn"
+social:
+  github: "zhravan/golearn"
🤖 Prompt for AI Agents
In docs/_config.yml around line 64, the github field currently uses the
placeholder "your-username/golearn" which produces broken links; replace that
value with the actual GitHub repository slug (for example "zhravan/golearn") so
all generated links that use site.social.github point to the correct repository.

twitter: "golearn_dev"
Loading