Skip to content

Commit a0e046f

Browse files
authored
Update readstat and GitHub actions (#777)
1 parent 575f438 commit a0e046f

26 files changed

+1819
-855
lines changed

.github/workflows/R-CMD-check.yaml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ on:
88
push:
99
branches: [main, master]
1010
pull_request:
11-
branches: [main, master]
1211

13-
name: R-CMD-check
12+
name: R-CMD-check.yaml
13+
14+
permissions: read-all
1415

1516
jobs:
1617
R-CMD-check:
@@ -25,24 +26,22 @@ jobs:
2526
- {os: macos-latest, r: 'release'}
2627

2728
- {os: windows-latest, r: 'release'}
28-
# Use 3.6 to trigger usage of RTools35
29-
- {os: windows-latest, r: '3.6'}
30-
# use 4.1 to check with rtools40's older compiler
31-
- {os: windows-latest, r: '4.1'}
32-
33-
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
34-
- {os: ubuntu-latest, r: 'release'}
35-
- {os: ubuntu-latest, r: 'oldrel-1'}
36-
- {os: ubuntu-latest, r: 'oldrel-2'}
37-
- {os: ubuntu-latest, r: 'oldrel-3'}
38-
- {os: ubuntu-latest, r: 'oldrel-4'}
29+
# use 4.0 or 4.1 to check with rtools40's older compiler
30+
- {os: windows-latest, r: 'oldrel-4'}
31+
32+
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
33+
- {os: ubuntu-latest, r: 'release'}
34+
- {os: ubuntu-latest, r: 'oldrel-1'}
35+
- {os: ubuntu-latest, r: 'oldrel-2'}
36+
- {os: ubuntu-latest, r: 'oldrel-3'}
37+
- {os: ubuntu-latest, r: 'oldrel-4'}
3938

4039
env:
4140
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
4241
R_KEEP_PKG_SOURCE: yes
4342

4443
steps:
45-
- uses: actions/checkout@v3
44+
- uses: actions/checkout@v4
4645

4746
- uses: r-lib/actions/setup-pandoc@v2
4847

@@ -60,3 +59,4 @@ jobs:
6059
- uses: r-lib/actions/check-r-package@v2
6160
with:
6261
upload-snapshots: true
62+
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'

.github/workflows/pkgdown.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ on:
44
push:
55
branches: [main, master]
66
pull_request:
7-
branches: [main, master]
87
release:
98
types: [published]
109
workflow_dispatch:
1110

12-
name: pkgdown
11+
name: pkgdown.yaml
12+
13+
permissions: read-all
1314

1415
jobs:
1516
pkgdown:
@@ -22,7 +23,7 @@ jobs:
2223
permissions:
2324
contents: write
2425
steps:
25-
- uses: actions/checkout@v3
26+
- uses: actions/checkout@v4
2627

2728
- uses: r-lib/actions/setup-pandoc@v2
2829

@@ -41,7 +42,7 @@ jobs:
4142

4243
- name: Deploy to GitHub pages 🚀
4344
if: github.event_name != 'pull_request'
44-
uses: JamesIves/github-pages-deploy-action@v4.4.1
45+
uses: JamesIves/github-pages-deploy-action@v4.5.0
4546
with:
4647
clean: false
4748
branch: gh-pages

.github/workflows/pr-commands.yaml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ on:
44
issue_comment:
55
types: [created]
66

7-
name: Commands
7+
name: pr-commands.yaml
8+
9+
permissions: read-all
810

911
jobs:
1012
document:
@@ -13,8 +15,10 @@ jobs:
1315
runs-on: ubuntu-latest
1416
env:
1517
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
18+
permissions:
19+
contents: write
1620
steps:
17-
- uses: actions/checkout@v3
21+
- uses: actions/checkout@v4
1822

1923
- uses: r-lib/actions/pr-fetch@v2
2024
with:
@@ -50,8 +54,10 @@ jobs:
5054
runs-on: ubuntu-latest
5155
env:
5256
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
57+
permissions:
58+
contents: write
5359
steps:
54-
- uses: actions/checkout@v3
60+
- uses: actions/checkout@v4
5561

5662
- uses: r-lib/actions/pr-fetch@v2
5763
with:

.github/workflows/test-coverage.yaml

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ on:
44
push:
55
branches: [main, master]
66
pull_request:
7-
branches: [main, master]
87

9-
name: test-coverage
8+
name: test-coverage.yaml
9+
10+
permissions: read-all
1011

1112
jobs:
1213
test-coverage:
@@ -15,36 +16,47 @@ jobs:
1516
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
1617

1718
steps:
18-
- uses: actions/checkout@v3
19+
- uses: actions/checkout@v4
1920

2021
- uses: r-lib/actions/setup-r@v2
2122
with:
2223
use-public-rspm: true
2324

2425
- uses: r-lib/actions/setup-r-dependencies@v2
2526
with:
26-
extra-packages: any::covr
27+
extra-packages: any::covr, any::xml2
2728
needs: coverage
2829

2930
- name: Test coverage
3031
run: |
31-
covr::codecov(
32+
cov <- covr::package_coverage(
3233
quiet = FALSE,
3334
clean = FALSE,
3435
install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package")
3536
)
37+
print(cov)
38+
covr::to_cobertura(cov)
3639
shell: Rscript {0}
3740

41+
- uses: codecov/codecov-action@v5
42+
with:
43+
# Fail if error if not on PR, or if on PR and token is given
44+
fail_ci_if_error: ${{ github.event_name != 'pull_request' || secrets.CODECOV_TOKEN }}
45+
files: ./cobertura.xml
46+
plugins: noop
47+
disable_search: true
48+
token: ${{ secrets.CODECOV_TOKEN }}
49+
3850
- name: Show testthat output
3951
if: always()
4052
run: |
4153
## --------------------------------------------------------------------
42-
find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true
54+
find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true
4355
shell: bash
4456

4557
- name: Upload test results
4658
if: failure()
47-
uses: actions/upload-artifact@v3
59+
uses: actions/upload-artifact@v4
4860
with:
4961
name: coverage-test-failures
5062
path: ${{ runner.temp }}/package

README.Rmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ knitr::opts_chunk$set(
1818
<!-- badges: start -->
1919
[![CRAN status](https://www.r-pkg.org/badges/version/haven)](https://cran.r-project.org/package=haven)
2020
[![R-CMD-check](https://github.com/tidyverse/haven/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/tidyverse/haven/actions/workflows/R-CMD-check.yaml)
21-
[![Codecov test coverage](https://codecov.io/gh/tidyverse/haven/branch/main/graph/badge.svg)](https://app.codecov.io/gh/tidyverse/haven?branch=main)
21+
[![Codecov test coverage](https://codecov.io/gh/tidyverse/haven/graph/badge.svg)](https://app.codecov.io/gh/tidyverse/haven)
2222
<!-- badges: end -->
2323

2424
## Overview

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
status](https://www.r-pkg.org/badges/version/haven)](https://cran.r-project.org/package=haven)
1010
[![R-CMD-check](https://github.com/tidyverse/haven/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/tidyverse/haven/actions/workflows/R-CMD-check.yaml)
1111
[![Codecov test
12-
coverage](https://codecov.io/gh/tidyverse/haven/branch/main/graph/badge.svg)](https://app.codecov.io/gh/tidyverse/haven?branch=main)
12+
coverage](https://codecov.io/gh/tidyverse/haven/graph/badge.svg)](https://app.codecov.io/gh/tidyverse/haven)
1313
<!-- badges: end -->
1414

1515
## Overview

src/cpp11.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ extern "C" SEXP _haven_write_xpt_(SEXP data, SEXP path, SEXP version, SEXP name,
110110

111111
extern "C" {
112112
/* .Call calls */
113-
extern SEXP is_tagged_na_(void *, void *);
114-
extern SEXP na_tag_(void *);
115-
extern SEXP tagged_na_(void *);
113+
extern SEXP is_tagged_na_(SEXP, SEXP);
114+
extern SEXP na_tag_(SEXP);
115+
extern SEXP tagged_na_(SEXP);
116116

117117
static const R_CallMethodDef CallEntries[] = {
118118
{"_haven_df_parse_dta_file", (DL_FUNC) &_haven_df_parse_dta_file, 6},

src/readstat/readstat.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,22 @@ typedef enum readstat_error_e {
104104
READSTAT_ERROR_TOO_FEW_COLUMNS,
105105
READSTAT_ERROR_TOO_MANY_COLUMNS,
106106
READSTAT_ERROR_NAME_IS_ZERO_LENGTH,
107-
READSTAT_ERROR_BAD_TIMESTAMP_VALUE
107+
READSTAT_ERROR_BAD_TIMESTAMP_VALUE,
108+
READSTAT_ERROR_BAD_MR_STRING
108109
} readstat_error_t;
109110

110111
const char *readstat_error_message(readstat_error_t error_code);
111112

113+
typedef struct mr_set_s {
114+
char type;
115+
char *name;
116+
char *label;
117+
int is_dichotomy;
118+
int counted_value;
119+
char **subvariables;
120+
int num_subvars;
121+
} mr_set_t;
122+
112123
typedef struct readstat_metadata_s {
113124
int64_t row_count;
114125
int64_t var_count;
@@ -121,6 +132,8 @@ typedef struct readstat_metadata_s {
121132
const char *file_label;
122133
const char *file_encoding;
123134
unsigned int is64bit:1;
135+
size_t multiple_response_sets_length;
136+
mr_set_t *mr_sets;
124137
} readstat_metadata_t;
125138

126139
/* If the row count is unknown (e.g. it's an XPORT or POR file, or an SAV
@@ -138,6 +151,8 @@ readstat_endian_t readstat_get_endianness(readstat_metadata_t *metadata);
138151
const char *readstat_get_table_name(readstat_metadata_t *metadata);
139152
const char *readstat_get_file_label(readstat_metadata_t *metadata);
140153
const char *readstat_get_file_encoding(readstat_metadata_t *metadata);
154+
const mr_set_t *readstat_get_multiple_response_sets(readstat_metadata_t *metadata);
155+
size_t readstat_get_multiple_response_sets_length(readstat_metadata_t *metadata);
141156

142157
typedef struct readstat_value_s {
143158
union {

src/readstat/readstat_metadata.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,11 @@ const char *readstat_get_file_encoding(readstat_metadata_t *metadata) {
4343
const char *readstat_get_table_name(readstat_metadata_t *metadata) {
4444
return metadata->table_name;
4545
}
46+
47+
size_t readstat_get_multiple_response_sets_length(readstat_metadata_t *metadata) {
48+
return metadata->multiple_response_sets_length;
49+
}
50+
51+
const mr_set_t *readstat_get_multiple_response_sets(readstat_metadata_t *metadata) {
52+
return metadata->mr_sets;
53+
}

src/readstat/sas/ieee.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ void ieee2xpt(unsigned char *ieee, unsigned char *xport) {
366366
shift = (int)
367367
(ieee_exp = (int)(((ieee1 >> 16) & 0x7ff0) >> 4) - 1023)
368368
& 3;
369-
/* the ieee format has an implied "1" immdeiately to the left */
369+
/* the ieee format has an implied "1" immediately to the left */
370370
/* of the binary point. Show it in here. */
371371
xport1 |= 0x00100000;
372372
if (shift)
@@ -377,7 +377,7 @@ void ieee2xpt(unsigned char *ieee, unsigned char *xport) {
377377
/* from the lower half that would have been shifted in (if */
378378
/* we could shift a double). The shift count can never */
379379
/* exceed 3, so all we care about are the high order 3 */
380-
/* bits. We don't want sign extention so make sure it's an */
380+
/* bits. We don't want sign extension so make sure it's an */
381381
/* unsigned char. We'll shift either5, 6, or 7 places to */
382382
/* keep 3, 2, or 1 bits. After that, shift the second half */
383383
/* of the number the right number of places. We always get */
@@ -391,9 +391,9 @@ void ieee2xpt(unsigned char *ieee, unsigned char *xport) {
391391

392392
/* Now set the ibm exponent and the sign of the fraction. The */
393393
/* power of 2 ieee exponent must be divided by 4 and made */
394-
/* excess 64 (we add 65 here because of the poisition of the */
394+
/* excess 64 (we add 65 here because of the position of the */
395395
/* fraction bits, essentially 4 positions lower than they */
396-
/* should be so we incrment the ibm exponent). */
396+
/* should be so we increment the ibm exponent). */
397397

398398
xport1 |=
399399

0 commit comments

Comments
 (0)