Skip to content

Commit

Permalink
Update CI to run 1.18 (#2374)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrerfcsantos authored Jul 19, 2022
1 parent 0fc2cba commit 89c3196
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 6 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/exercise-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ jobs:
strategy:
fail-fast: false
matrix:
go-version: [1.17.x]
go-version: [1.18.x]
os: [ubuntu-latest, windows-latest, macOS-latest]
test-arch: [amd64]
race: ['-race']

include:
- go-version: 1.17.x
- go-version: 1.18.x
test-arch: '386'
os: ubuntu-latest
race: ''
- go-version: 1.17.x
- go-version: 1.18.x
test-arch: '386'
os: windows-latest
race: ''
Expand Down
2 changes: 1 addition & 1 deletion bin/fetch-golangci-lint
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash

curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.43.0
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.46.2
50 changes: 49 additions & 1 deletion exercises/practice/accumulate/accumulate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,62 @@ import (
"fmt"
"strings"
"testing"
"unicode"
)

// Title is a copy of strings.Title function of the stdlib.
// The copy is here because strings.Title is deprecated but we still
// want to use this function as the alternative would require us to support
// external dependencies which we don't yet (tracking issue https://github.com/exercism/go/issues/2379).
// Students should still be able to use strings.Title if they want.
// Since this exercise is currently deprecated, this shouldn't matter too much.
func Title(s string) string {
// Use a closure here to remember state.
// Hackish but effective. Depends on Map scanning in order and calling
// the closure once per rune.
prev := ' '
return strings.Map(
func(r rune) rune {
if isSeparator(prev) {
prev = r
return unicode.ToTitle(r)
}
prev = r
return r
},
s)
}

// Copy of strings.isSeparator function of the stdlib.
func isSeparator(r rune) bool {
// ASCII alphanumerics and underscore are not separators
if r <= 0x7F {
switch {
case '0' <= r && r <= '9':
return false
case 'a' <= r && r <= 'z':
return false
case 'A' <= r && r <= 'Z':
return false
case r == '_':
return false
}
return true
}
// Letters and digits are not separators
if unicode.IsLetter(r) || unicode.IsDigit(r) {
return false
}
// Otherwise, all we can do for now is treat spaces as separators.
return unicode.IsSpace(r)
}

func echo(c string) string {
return c
}

func capitalize(word string) string {
return strings.Title(word)
return Title(word)
}

var tests = []struct {
Expand Down
49 changes: 48 additions & 1 deletion exercises/practice/scale-generator/.meta/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,55 @@ package scale

import (
"strings"
"unicode"
)

// Title is a copy of strings.Title function of the stdlib.
// The copy is here because strings.Title is deprecated but we still
// want to use this function as the alternative would require us to support
// external dependencies which we don't yet (tracking issue https://github.com/exercism/go/issues/2379).
// Students should still be able to use strings.Title if they want.
func Title(s string) string {
// Use a closure here to remember state.
// Hackish but effective. Depends on Map scanning in order and calling
// the closure once per rune.
prev := ' '
return strings.Map(
func(r rune) rune {
if isSeparator(prev) {
prev = r
return unicode.ToTitle(r)
}
prev = r
return r
},
s)
}

// Copy of strings.isSeparator function of the stdlib.
func isSeparator(r rune) bool {
// ASCII alphanumerics and underscore are not separators
if r <= 0x7F {
switch {
case '0' <= r && r <= '9':
return false
case 'a' <= r && r <= 'z':
return false
case 'A' <= r && r <= 'Z':
return false
case r == '_':
return false
}
return true
}
// Letters and digits are not separators
if unicode.IsLetter(r) || unicode.IsDigit(r) {
return false
}
// Otherwise, all we can do for now is treat spaces as separators.
return unicode.IsSpace(r)
}

var chromaticScale = []string{"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"}
var flatChromaticScale = []string{"C", "Db", "D", "Eb", "E", "F", "Gb", "G", "Ab", "A", "Bb", "B"}
var flatKeys = []string{"F", "Bb", "Eb", "Ab", "Db", "Gb", "d", "g", "c", "f", "bb", "eb"}
Expand Down Expand Up @@ -56,5 +103,5 @@ func formatTonic(tonic string) string {
if len(tonic) == 1 {
return strings.ToUpper(tonic)
}
return strings.Title(tonic)
return Title(tonic)
}

0 comments on commit 89c3196

Please sign in to comment.