Skip to content

Commit 4afb3ba

Browse files
authored
Merge pull request #4 from TidierOrg/add-pipeline-file
Add Pipeline File
2 parents f63385e + f536171 commit 4afb3ba

File tree

5 files changed

+119
-2
lines changed

5 files changed

+119
-2
lines changed

.github/workflows/CI.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: CI
2+
on:
3+
push:
4+
branches:
5+
- main
6+
tags: ["*"]
7+
pull_request:
8+
concurrency:
9+
# Skip intermediate builds: always.
10+
# Cancel intermediate builds: only if it is a pull request build.
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
13+
jobs:
14+
test:
15+
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
16+
runs-on: ${{ matrix.os }}
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
version:
21+
- "1.10"
22+
- "nightly"
23+
os:
24+
- ubuntu-latest
25+
arch:
26+
- x64
27+
steps:
28+
- uses: actions/checkout@v3
29+
- uses: julia-actions/setup-julia@v1
30+
with:
31+
version: ${{ matrix.version }}
32+
arch: ${{ matrix.arch }}
33+
- uses: julia-actions/cache@v1
34+
- uses: julia-actions/julia-buildpkg@v1
35+
- uses: julia-actions/julia-runtest@v1
36+
- uses: julia-actions/julia-processcoverage@v1
37+
- uses: coverallsapp/github-action@v1.1.2
38+
with:
39+
github-token: ${{ github.token }}
40+
path-to-lcov: lcov.info
41+
fail-on-error: false

Project.toml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "TidierTuesday"
22
uuid = "e5e0dc1b-0480-4754-b82b-fe0573bb955c"
3-
authors = ['nolan cauley']
4-
contributors = ['frank hull']
3+
authors = ["nolan cauley"]
4+
contributors = ["frank hull"]
55
version = "0.1.3"
66

77
[deps]
@@ -11,9 +11,16 @@ Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
1111
HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3"
1212
JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
1313

14+
[extras]
15+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
16+
17+
[targets]
18+
test = ["Test"]
19+
1420
[compat]
1521
CSV = "0.10"
1622
DataFrames = "1.5"
1723
HTTP = "1.9"
1824
JSON3 = "1.13"
25+
Test = "1.8"
1926
julia = "1.6"

test/dates_tests.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using Test
2+
using Dates
3+
4+
@testset "Dates functionality" begin
5+
6+
@testset "get_last_tuesday" begin
7+
# Test with a known date
8+
test_date = Date(2024, 4, 15) # Monday
9+
last_tuesday = get_last_tuesday(test_date)
10+
@test last_tuesday == Date(2024, 4, 9)
11+
12+
# Test with a Tuesday
13+
test_date = Date(2024, 4, 9) # Tuesday
14+
last_tuesday = get_last_tuesday(test_date)
15+
@test last_tuesday == Date(2024, 4, 9)
16+
end
17+
end

test/load_tests.jl

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using Test
2+
using Dates
3+
4+
# Set up test environment
5+
const TEST_CACHE_DIR = joinpath(@__DIR__, "test_cache")
6+
7+
@testset "Load functionality" begin
8+
9+
# Create test fixture file
10+
test_file = joinpath(TEST_CACHE_DIR, "02-04-2024", "test_dataset.csv")
11+
mkpath(dirname(test_file))
12+
write(test_file, "col1,col2,col3\n1,2,3\n4,5,6\n7,8,9\n")
13+
14+
@testset "tt_load" begin
15+
16+
# verify default cache directory
17+
@test get_cache_dir() == joinpath(homedir(), ".tidytuesday", "cache")
18+
19+
# set cache directory
20+
set_cache_dir(TEST_CACHE_DIR)
21+
@test get_cache_dir() == TEST_CACHE_DIR
22+
23+
# Test loading a dataset
24+
tuple = tt_load("02-04-2024", use_cache=true)
25+
df = tuple.test_dataset
26+
27+
# Test DataFrame structure
28+
@test nrow(df) == 3
29+
@test names(df) == ["col1", "col2", "col3"]
30+
31+
end
32+
33+
# Clean up test files
34+
rm(test_file)
35+
rm(joinpath(TEST_CACHE_DIR), recursive=true, force=true)
36+
end

test/runtests.jl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using TidierTuesday
2+
using Test
3+
using DataFrames
4+
using CSV
5+
using Dates
6+
7+
@testset "TidierTuesday.jl" begin
8+
9+
@testset "Dates" begin
10+
include("dates_tests.jl")
11+
end
12+
13+
@testset "Load" begin
14+
include("load_tests.jl")
15+
end
16+
end

0 commit comments

Comments
 (0)