Skip to content
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

Add CI jobs for Windows #151

Merged
merged 35 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
a3e0aeb
Try building single-file package on windows
chiphogg Jul 8, 2023
2103502
Try compiling with MSVC
chiphogg Jul 8, 2023
3bd9e40
Remove blank lines
chiphogg Jul 8, 2023
62f27c5
Try specifying branch
chiphogg Jul 8, 2023
8120210
Go back to previous configuration
chiphogg Jul 8, 2023
97e6f0d
Try listing all files
chiphogg Jul 8, 2023
ba26ce1
Try dir command instead
chiphogg Jul 8, 2023
b385aaf
Try running python script without bazel
chiphogg Jul 8, 2023
de85d43
Use python 3.10 generically
chiphogg Jul 8, 2023
3edc15f
Dump au.hh
chiphogg Jul 8, 2023
bfb4374
Try fixing file
chiphogg Jul 8, 2023
db9e5cc
Try adding version number from my computer
chiphogg Jul 8, 2023
1018422
Shot in the dark at another value
chiphogg Jul 8, 2023
9574b49
Try setting C++14 standard
chiphogg Jul 8, 2023
34181d3
See if C++17 fixes it
chiphogg Jul 8, 2023
4e300f6
Try newer version of windows
chiphogg Jul 8, 2023
4a6efb4
Shot in the dark
chiphogg Jul 8, 2023
09e1a1e
Try another workaround
chiphogg Jul 8, 2023
c79b614
Make sure failing test will fail GitHub action
chiphogg Jul 8, 2023
a848973
Fix test
chiphogg Jul 8, 2023
c8932b2
Clean up workflow file
chiphogg Jul 8, 2023
8c6dce0
Sanity check: we do need msvc-dev-cmd, right?
chiphogg Jul 8, 2023
0ad8cca
Yep, we need it
chiphogg Jul 8, 2023
605636d
Revert "Fix compiler errors on MSVC v142 (#146)"
chiphogg Jul 8, 2023
0826649
Does windows-2019 have an older compiler?
chiphogg Jul 8, 2023
d23b14d
Re-apply "Fix compiler errors on MSVC v142 (#146)"
chiphogg Jul 8, 2023
15df5ad
Merge branch 'main' into add-single-file-actions#144
chiphogg Jul 24, 2023
a2ec8e1
Describe test file
chiphogg Jul 24, 2023
dcc9472
Try adding two versions of Windows
chiphogg Jul 24, 2023
e84e088
Bump the matrix up a level
chiphogg Jul 24, 2023
9e5d1cd
Remove quotes
chiphogg Jul 24, 2023
3b61a3d
Fix typo
chiphogg Jul 24, 2023
8adb30b
Set final push policy
chiphogg Jul 24, 2023
b3c3fec
Add license header
chiphogg Jul 24, 2023
a2e0b78
Remove unused parameter name
chiphogg Jul 24, 2023
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
50 changes: 50 additions & 0 deletions .github/workflows/single-file-build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Copyright 2023 Aurora Operations, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: single-file-build-and-test

on:
push:
branches:
- main
pull_request:

jobs:
build:
strategy:
matrix:
windows: [windows-2019, windows-2022]

runs-on: ${{ matrix.windows }}

steps:
- uses: actions/checkout@dc323e67f16fb5f7663d20ff7941f27f5809e9b6 #v2.6.0

- name: Set up developer command prompt
uses: ilammy/msvc-dev-cmd@cec98b9d092141f74527d0afa6feb2af698cfe89 #v1.12.1

- name: Set up python
uses: actions/setup-python@3542bca2639a428e1796aaa6a2ffef0c0f575566 #v3.1.4
with:
python-version: '3.10'

- name: Build single-file package
shell: cmd
run: python tools/bin/make-single-file --units meters seconds --version-id NA > au.hh

- name: Build and run test
shell: cmd
run: |
cl.exe /std:c++14 single-file-test.cc
single-file-test.exe
6 changes: 3 additions & 3 deletions au/quantity.hh
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ class Quantity {
template <typename NewRep,
typename NewUnit,
typename = std::enable_if_t<IsUnit<NewUnit>::value>>
constexpr auto as(NewUnit u) const {
constexpr auto ratio = unit_ratio(unit, u);
constexpr auto as(NewUnit) const {
constexpr auto ratio = unit_ratio(unit, NewUnit{});

using Common = std::common_type_t<Rep, NewRep>;
constexpr auto NUM = integer_part(numerator(ratio));
Expand All @@ -158,7 +158,7 @@ class Quantity {

template <typename NewUnit, typename = std::enable_if_t<IsUnit<NewUnit>::value>>
constexpr auto as(NewUnit u) const {
static_assert(implicit_rep_permitted_from_source_to_target<Rep>(unit, u),
static_assert(implicit_rep_permitted_from_source_to_target<Rep>(unit, NewUnit{}),
"Dangerous conversion: use .as<Rep>(NewUnit) instead");
return as<Rep>(u);
}
Expand Down
48 changes: 48 additions & 0 deletions single-file-test.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Copyright 2023 Aurora Operations, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include <algorithm>
#include <iostream>
#include <vector>

#include "au.hh"

// This file builds all of the code in the single-file package of Au, and runs some basic tests.
//
// If we find any failures not covered by this file, we can add more test cases as needed.
//
// Note that this file will *not* be built with bazel. It's therefore important that we avoid all
// dependencies outside of the C++14 standard library, and the single-file package of Au itself.

using namespace au;

// This ad hoc utility is a stand-in for GTEST, which we can't use here.
template <typename ExpectedT, typename ActualT>
bool expect_equal(ExpectedT expected, ActualT actual) {
if (expected != actual) {
std::cerr << "Failure! Expected (" << expected << "); Actual (" << actual << ")"
<< std::endl;
return false;
}
return true;
}

int main(int argc, char **argv) {
const std::vector<bool> results{
{
expect_equal((meters / second)(5) * seconds(6), meters(30)),
},
};
return std::all_of(std::begin(results), std::end(results), [](auto x) { return x; }) ? 0 : 1;
}