Browse Source

Migrate CI to GitHub Actions

gh-actions
Alex Crichton 5 years ago
parent
commit
990383cbff
  1. 122
      .github/workflows/main.yml
  2. 2
      README.md
  3. 105
      azure-pipelines.yml
  4. 38
      ci/azure-install-rust.yml
  5. 28
      ci/azure-steps.yml
  6. 12
      src/com.rs
  7. 4
      src/setup_config.rs
  8. 16
      src/windows_registry.rs
  9. 2
      tests/cflags.rs
  10. 2
      tests/cxxflags.rs

122
.github/workflows/main.yml

@ -0,0 +1,122 @@
name: CI
on: [push, pull_request]
jobs:
test:
name: Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
build: [stable, beta, nightly, linux32, macos, aarch64-ios, win32, win64, mingw32, mingw64, windows-2016]
include:
- build: stable
os: ubuntu-latest
rust: stable
target: x86_64-unknown-linux-gnu
- build: beta
os: ubuntu-latest
rust: beta
target: x86_64-unknown-linux-gnu
- build: nightly
os: ubuntu-latest
rust: nightly
target: x86_64-unknown-linux-gnu
- build: linux32
os: ubuntu-latest
rust: stable
target: i686-unknown-linux-gnu
- build: macos
os: macos-latest
rust: stable
target: x86_64-apple-darwin
- build: aarch64-ios
os: macos-latest
rust: stable
target: aarch64-apple-ios
no_run: --no-run
- build: win32
os: windows-2016
rust: stable-i686-msvc
target: i686-pc-windows-msvc
- build: win64
os: windows-latest
rust: stable
target: x86_64-pc-windows-msvc
- build: mingw32
os: windows-latest
rust: stable-i686-gnu
target: i686-pc-windows-gnu
- build: mingw64
os: windows-latest
rust: stable-x86_64-gnu
target: x86_64-pc-windows-gnu
- build: windows-2016
os: windows-2016
rust: stable-x86_64
target: x86_64-pc-windows-msvc
steps:
- uses: actions/checkout@master
- name: Install Rust (rustup)
run: rustup update ${{ matrix.rust }} && rustup default ${{ matrix.rust }}
if: matrix.os != 'macos-latest'
- name: Install Rust (macos)
run: |
curl https://sh.rustup.rs | sh -s -- -y
echo "##[add-path]$HOME/.cargo/bin"
if: matrix.os == 'macos-latest'
- run: rustup target add ${{ matrix.target }}
- name: Install g++-multilib
run: |
set -e
# Remove the ubuntu-toolchain-r/test PPA, which is added by default.
# Some packages were removed, and this is causing the g++multilib
# install to fail. Similar issue:
# https://github.com/scikit-learn/scikit-learn/issues/13928.
sudo add-apt-repository --remove ppa:ubuntu-toolchain-r/test
sudo apt-get install g++-multilib
if: matrix.build == 'linux32'
- run: cargo build
- run: cargo test ${{ matrix.no_run }}
- run: cargo test ${{ matrix.no_run }} --features parallel
- run: cargo test ${{ matrix.no_run }} --manifest-path cc-test/Cargo.toml --target ${{ matrix.target }}
- run: cargo test ${{ matrix.no_run }} --manifest-path cc-test/Cargo.toml --target ${{ matrix.target }} --features parallel
- run: cargo test ${{ matrix.no_run }} --manifest-path cc-test/Cargo.toml --target ${{ matrix.target }} --release
msrv:
name: MSRV
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@master
- name: Install Rust
run: rustup update 1.31.0 && rustup default 1.31.0
- run: cargo build
rustfmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Install Rust
run: rustup update stable && rustup default stable && rustup component add rustfmt
- run: cargo fmt -- --check
publish_docs:
name: Publish Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Install Rust
run: rustup update stable && rustup default stable
- name: Build documentation
run: cargo doc --no-deps --all-features
- name: Publish documentation
run: |
cd target/doc
git init
git add .
git -c user.name='ci' -c user.email='ci' commit -m init
git push -f -q https://git:${{ secrets.github_token }}@github.com/${{ github.repository }} HEAD:gh-pages
if: github.event_name == 'push' && github.event.ref == 'refs/heads/master'

2
README.md

@ -2,8 +2,6 @@
A library to compile C/C++/assembly into a Rust library/application.
[![Build Status](https://dev.azure.com/alexcrichton/cc-rs/_apis/build/status/alexcrichton.cc-rs?branchName=master)](https://dev.azure.com/alexcrichton/cc-rs/_build/latest?definitionId=5&branchName=master)
[Documentation](https://docs.rs/cc)
A simple library meant to be used as a build dependency with Cargo packages in

105
azure-pipelines.yml

@ -1,105 +0,0 @@
# Note for forks: Azure Pipelines is triggered only by commits to the branches
# matching the patterns below.
# See https://docs.microsoft.com/en-us/azure/devops/pipelines/build/triggers
trigger:
- master
- ci-*
jobs:
- job: min_linux
pool:
vmImage: ubuntu-16.04
displayName: Minimum Rust (Linux)
variables:
TOOLCHAIN: 1.31.0
steps:
- template: ci/azure-install-rust.yml
- script: cargo build
- job: min_Windows
pool:
vmImage: vs2017-win2016
displayName: Minimum Rust (Windows)
variables:
TOOLCHAIN: 1.31.0
steps:
- template: ci/azure-install-rust.yml
- script: cargo build
- job: Linux
pool:
vmImage: ubuntu-16.04
steps:
- template: ci/azure-steps.yml
strategy:
matrix:
x86_64:
TARGET: x86_64-unknown-linux-gnu
i686:
TARGET: i686-unknown-linux-gnu
x86_64-beta:
TARGET: x86_64-unknown-linux-gnu
TOOLCHAIN: beta
x86_64-nightly:
TARGET: x86_64-unknown-linux-gnu
TOOLCHAIN: nightly
- job: macOS
pool:
vmImage: macos-10.13
steps:
- template: ci/azure-steps.yml
strategy:
matrix:
x86_64:
TARGET: x86_64-apple-darwin
aarch64-ios:
TARGET: aarch64-apple-ios
NO_RUN: --no-run
- job: Windows_vs2019
pool:
vmImage: windows-2019
steps:
- template: ci/azure-steps.yml
strategy:
matrix:
x86_64-msvc:
TARGET: x86_64-pc-windows-msvc
- job: Windows_vs2017
pool:
vmImage: vs2017-win2016
steps:
- template: ci/azure-steps.yml
strategy:
matrix:
x86_64-msvc:
TARGET: x86_64-pc-windows-msvc
i686-msvc:
TARGET: i686-pc-windows-msvc
x86_64-gnu:
TARGET: x86_64-pc-windows-gnu
i686-gnu:
TARGET: i686-pc-windows-gnu
- job: Windows_vs2015
pool:
vmImage: vs2015-win2012r2
steps:
- template: ci/azure-steps.yml
strategy:
matrix:
x86_64-msvc:
TARGET: x86_64-pc-windows-msvc
i686-msvc:
TARGET: i686-pc-windows-msvc
- job: docs
steps:
- template: ci/azure-install-rust.yml
- script: cargo doc --no-deps --all-features
- script: curl -LsSf https://git.io/fhJ8n | rustc - && (cd target/doc && ../../rust_out)
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
env:
GITHUB_DEPLOY_KEY: $(GITHUB_DEPLOY_KEY)

38
ci/azure-install-rust.yml

@ -1,38 +0,0 @@
steps:
- bash: |
set -e
toolchain=$TOOLCHAIN
if [ "$toolchain" = "" ]; then
toolchain=stable
fi
if command -v rustup; then
rustup update $toolchain
rustup default $toolchain
else
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain $toolchain
echo "##vso[task.prependpath]$HOME/.cargo/bin"
fi
displayName: Install rust (unix)
condition: ne( variables['Agent.OS'], 'Windows_NT' )
- bash: |
set -e
toolchain=$TOOLCHAIN
if [ "$toolchain" = "" ]; then
toolchain=stable-$TARGET
fi
if command -v rustup; then
rustup update --no-self-update $toolchain
rustup default $toolchain
else
curl.exe -sSf -o rustup-init.exe https://win.rustup.rs
./rustup-init.exe -y --default-toolchain $toolchain
echo "##vso[task.prependpath]$USERPROFILE/.cargo/bin"
fi
displayName: Install rust (windows)
condition: eq( variables['Agent.OS'], 'Windows_NT' )
- script: |
rustc -Vv
cargo -V
displayName: Query rust and cargo versions

28
ci/azure-steps.yml

@ -1,28 +0,0 @@
steps:
- template: azure-install-rust.yml
- bash: rustup target add $TARGET
displayName: Install Rust target
# Remove the ubuntu-toolchain-r/test PPA, which is added by default. Some
# packages were removed, and this is causing the g++multilib install to fail.
# Similar issue: https://github.com/scikit-learn/scikit-learn/issues/13928
- bash: sudo add-apt-repository --remove ppa:ubuntu-toolchain-r/test
condition: eq( variables['Agent.OS'], 'Linux' )
displayName: Remove ppa:ubuntu-toolchain-r/test
- bash: sudo apt-get install g++-multilib
condition: eq( variables['Agent.OS'], 'Linux' )
displayName: Install g++-multilib
- script: cargo build
displayName: "Normal build"
- bash: cargo test $NO_RUN
displayName: "Crate tests"
- bash: cargo test $NO_RUN --features parallel
displayName: "Crate tests (parallel)"
- bash: cargo test $NO_RUN --manifest-path cc-test/Cargo.toml --target $TARGET
displayName: "cc-test tests"
- bash: cargo test $NO_RUN --manifest-path cc-test/Cargo.toml --target $TARGET --features parallel
displayName: "cc-test tests (parallel)"
- bash: cargo test $NO_RUN --manifest-path cc-test/Cargo.toml --target $TARGET --release
displayName: "cc-test tests (release)"

12
src/com.rs

@ -7,12 +7,6 @@
#![allow(unused)]
use std::ffi::{OsStr, OsString};
use std::mem::forget;
use std::ops::Deref;
use std::os::windows::ffi::{OsStrExt, OsStringExt};
use std::ptr::null_mut;
use std::slice::from_raw_parts;
use crate::winapi::CoInitializeEx;
use crate::winapi::IUnknown;
use crate::winapi::Interface;
@ -20,6 +14,12 @@ use crate::winapi::BSTR;
use crate::winapi::COINIT_MULTITHREADED;
use crate::winapi::{SysFreeString, SysStringLen};
use crate::winapi::{HRESULT, S_FALSE, S_OK};
use std::ffi::{OsStr, OsString};
use std::mem::forget;
use std::ops::Deref;
use std::os::windows::ffi::{OsStrExt, OsStringExt};
use std::ptr::null_mut;
use std::slice::from_raw_parts;
pub fn initialize() -> Result<(), HRESULT> {
let err = unsafe { CoInitializeEx(null_mut(), COINIT_MULTITHREADED) };

4
src/setup_config.rs

@ -8,8 +8,6 @@
#![allow(bad_style)]
#![allow(unused)]
use std::ffi::OsString;
use std::ptr::null_mut;
use crate::winapi::Interface;
use crate::winapi::BSTR;
use crate::winapi::LPCOLESTR;
@ -19,6 +17,8 @@ use crate::winapi::{CoCreateInstance, CLSCTX_ALL};
use crate::winapi::{IUnknown, IUnknownVtbl};
use crate::winapi::{HRESULT, LCID, LPCWSTR, PULONGLONG};
use crate::winapi::{LPFILETIME, ULONG};
use std::ffi::OsString;
use std::ptr::null_mut;
use crate::com::{BStr, ComPtr};

16
src/windows_registry.rs

@ -313,8 +313,7 @@ mod impl_ {
}
fn tool_from_vs15_instance(tool: &str, target: &str, instance: &SetupInstance) -> Option<Tool> {
let (bin_path, host_dylib_path, lib_path, include_path) =
vs15_vc_paths(target, instance)?;
let (bin_path, host_dylib_path, lib_path, include_path) = vs15_vc_paths(target, instance)?;
let tool_path = bin_path.join(tool);
if !tool_path.exists() {
return None;
@ -520,12 +519,13 @@ mod impl_ {
let max_libdir = readdir
.filter_map(|dir| dir.ok())
.map(|dir| dir.path())
.filter(|dir| dir
.components()
.last()
.and_then(|c| c.as_os_str().to_str())
.map(|c| c.starts_with("10.") && dir.join("ucrt").is_dir())
.unwrap_or(false))
.filter(|dir| {
dir.components()
.last()
.and_then(|c| c.as_os_str().to_str())
.map(|c| c.starts_with("10.") && dir.join("ucrt").is_dir())
.unwrap_or(false)
})
.max()?;
let version = max_libdir.components().last().unwrap();
let version = version.as_os_str().to_str().unwrap().to_string();

2
tests/cflags.rs

@ -1,7 +1,7 @@
mod support;
use std::env;
use crate::support::Test;
use std::env;
/// This test is in its own module because it modifies the environment and would affect other tests
/// when run in parallel with them.

2
tests/cxxflags.rs

@ -1,7 +1,7 @@
mod support;
use std::env;
use crate::support::Test;
use std::env;
/// This test is in its own module because it modifies the environment and would affect other tests
/// when run in parallel with them.

Loading…
Cancel
Save